为什么只有三十分啊
查看原帖
为什么只有三十分啊
1139123
Davnaver楼主2024/3/27 20:50
#include <vector>
#include <iostream> 
#include <algorithm>
using namespace std;
int main() {
	int m, n, t, ans = 0;
	cin >> m >> n;
	vector<int> v; // 用来表示内存
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		if (find(v.begin(), v.end(), t) == v.end())
		{
			v.push_back(t);
			ans++;
		}
		if (v.size() > m)
		{
			v.pop_back();
		}
	}
	cout << ans << endl;
}
2024/3/27 20:50
加载中...