/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 35ms 532.0 KiB
#3 Accepted 27ms 532.0 KiB
#4 Accepted 29ms 532.0 KiB
#5 Accepted 26ms 532.0 KiB
#6 Accepted 27ms 324.0 KiB
#7 Accepted 27ms 532.0 KiB
#8 Accepted 29ms 532.0 KiB
#9 Accepted 27ms 532.0 KiB
#10 Accepted 27ms 532.0 KiB
#11 Accepted 26ms 560.0 KiB
#12 Accepted 26ms 532.0 KiB
#13 Accepted 33ms 532.0 KiB
#14 Accepted 27ms 324.0 KiB
#15 Accepted 26ms 532.0 KiB
#16 Accepted 55ms 536.0 KiB
#17 Accepted 29ms 324.0 KiB
#18 Accepted 27ms 328.0 KiB
#19 Accepted 26ms 532.0 KiB
#20 Accepted 27ms 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-05 15:54:48
Judged By
Score
100
Total Time
55ms
Peak Memory
560.0 KiB