Wrong Answer
Code
#include <bits/stdc++.h>
#define ll long long
#define pub push_back
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0);
using namespace std;
void solve()
{
int n;
cin >> n;
map<int, int> mp;
ll s = 0;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
if (x == 0)
continue;
if (mp[x] == 1)
s += x;
mp[x] = 1;
}
int i;
for (i = 1;; i++)
{
if (mp[i] == 0)
{
if (s >= i)
{
s -= i;
}
else
{
break;
}
}
}
cout << i << endl;
}
int main()
{
fast;
ll t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1114 Maximize the MEX
- Contest
- Brain Booster #7
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-05 15:50:09
- Judged At
- 2024-11-05 15:50:09
- Judged By
- Score
- 5
- Total Time
- 134ms
- Peak Memory
- 8.77 MiB