/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 20ms 572.0 KiB
#3 Accepted 49ms 1.309 MiB
#4 Accepted 50ms 1.316 MiB
#5 Accepted 49ms 1.309 MiB
#6 Accepted 49ms 1.312 MiB
#7 Accepted 49ms 1.312 MiB
#8 Accepted 49ms 1.312 MiB
#9 Accepted 50ms 1.309 MiB
#10 Accepted 50ms 1.312 MiB
#11 Accepted 48ms 1.301 MiB
#12 Accepted 49ms 1.312 MiB
#13 Accepted 49ms 1.32 MiB
#14 Accepted 49ms 1.297 MiB
#15 Accepted 49ms 1.309 MiB
#16 Accepted 49ms 1.312 MiB
#17 Accepted 49ms 1.312 MiB
#18 Accepted 49ms 1.188 MiB
#19 Accepted 49ms 1.312 MiB
#20 Accepted 49ms 1.312 MiB

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-11 02:32:15
Judged By
Score
100
Total Time
50ms
Peak Memory
1.32 MiB