/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 32ms 568.0 KiB
#3 Accepted 68ms 1.312 MiB
#4 Accepted 69ms 1.309 MiB
#5 Accepted 67ms 1.312 MiB
#6 Accepted 67ms 1.324 MiB
#7 Accepted 68ms 1.309 MiB
#8 Accepted 68ms 1.312 MiB
#9 Accepted 67ms 1.312 MiB
#10 Accepted 67ms 1.312 MiB
#11 Accepted 68ms 1.309 MiB
#12 Accepted 64ms 1.316 MiB
#13 Accepted 44ms 1.504 MiB
#14 Accepted 45ms 1.316 MiB
#15 Accepted 45ms 1.547 MiB
#16 Accepted 44ms 1.277 MiB
#17 Accepted 47ms 1.316 MiB
#18 Accepted 45ms 1.301 MiB
#19 Accepted 45ms 1.277 MiB
#20 Accepted 44ms 1.277 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-05 14:53:18
Judged By
Score
100
Total Time
69ms
Peak Memory
1.547 MiB