关于昨晚CFdiv2的C
  • 板块灌水区
  • 楼主Vitamin_B
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/3/17 22:11
  • 上次更新2024/3/18 13:25:50
查看原帖
关于昨晚CFdiv2的C
743373
Vitamin_B楼主2024/3/17 22:11

rt,被这个数据卡了,但我觉得答案就是2(标准答案是3),我认为Bob可以直接偷袭唯一一个2,然后使c中的mex变成2,数据:

9
1 0 7 7 7 6 1 2 0
# include <bits/stdc++.h>

# define ffor(i,name) \
	for (auto i = name.begin (); i != name.end (); ++ i)

using namespace std;

typedef long long ll;

typedef pair <int, int> pii;

int t, n, a[200005], x, now;

int main () {

	ios::sync_with_stdio (0);

	cin.tie (0);

	cout.tie (0);

	cin >> t;

	while (t --) {

		cin >> n;

		for (int i = 0; i <= n; ++ i)
			a[i] = 0;

		for (int i = 0; i < n; ++ i)
			cin >> x, ++ a[x];

		now = 0;

		for (int i = 0; i <= n; ++ i)
			if (now >= a[i]) {

				cout << i << '\n';

				break ;

			} else
				++ now;

	}

	return 0;

}
/*
1
9
1 0 7 7 7 6 1 2 0
*/ 
2024/3/17 22:11
加载中...