/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Accepted 35ms 584.0 KiB
#3 Accepted 29ms 532.0 KiB
#4 Accepted 29ms 536.0 KiB
#5 Accepted 29ms 532.0 KiB
#6 Accepted 29ms 556.0 KiB
#7 Accepted 29ms 532.0 KiB
#8 Accepted 29ms 560.0 KiB
#9 Accepted 29ms 328.0 KiB
#10 Accepted 29ms 320.0 KiB
#11 Accepted 29ms 324.0 KiB
#12 Accepted 29ms 560.0 KiB
#13 Accepted 29ms 532.0 KiB
#14 Accepted 29ms 560.0 KiB
#15 Accepted 29ms 320.0 KiB
#16 Accepted 29ms 548.0 KiB
#17 Accepted 29ms 324.0 KiB
#18 Accepted 29ms 324.0 KiB
#19 Accepted 29ms 324.0 KiB
#20 Accepted 29ms 532.0 KiB

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()
{
    ll n;
    cin >> n;
    ll s = 0;
    for (ll i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        s += x;
    }
    ll i;
    for (i = 1;; i++)
    {
        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:54:48
Judged At
2024-11-11 02:29:23
Judged By
Score
100
Total Time
35ms
Peak Memory
584.0 KiB