Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
using ll = long long;
int main() {
FAST;
int tc = 1, ti;
cin >> tc;
for (ti = 1; ti <= tc; ++ti) {
ll n, i, x, sum, curr;
cin >> n;
vector<ll> a(n);
for (i = 0; i < n; ++i) cin >> a[i];
sort(a.begin(), a.end());
sum = accumulate(a.begin(), a.end(), 0ll);
x = 0;
curr = 0;
while (curr <= sum) {
x += 1;
curr += x;
}
cout << x << "\n";
}
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 14:53:18
- Judged At
- 2024-11-05 14:53:18
- Judged By
- Score
- 100
- Total Time
- 69ms
- Peak Memory
- 1.547 MiB