/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 492.0 KiB
#2 Accepted 42ms 592.0 KiB
#3 Accepted 34ms 948.0 KiB
#4 Accepted 39ms 948.0 KiB
#5 Accepted 40ms 944.0 KiB
#6 Accepted 38ms 944.0 KiB
#7 Accepted 45ms 952.0 KiB
#8 Accepted 43ms 944.0 KiB
#9 Accepted 43ms 948.0 KiB
#10 Accepted 38ms 956.0 KiB
#11 Accepted 38ms 944.0 KiB
#12 Accepted 38ms 956.0 KiB
#13 Accepted 37ms 948.0 KiB
#14 Accepted 43ms 948.0 KiB
#15 Accepted 39ms 948.0 KiB
#16 Accepted 38ms 944.0 KiB
#17 Accepted 42ms 948.0 KiB
#18 Accepted 44ms 948.0 KiB
#19 Accepted 38ms 944.0 KiB
#20 Accepted 38ms 944.0 KiB

Code

#include<bits/stdc++.h>
#define ll long long
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define testing cout << "testing ";
#define mod 1000000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;


void do_the_honour(){

    int n;cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];

    ll sum=accumulate(a,a+n,0LL);
    ll x=sum;
    ll nn = (-1 + sqrtl(1 + 8 * x)) / 2;


    cout << nn+1 << endl;

}

int main(){
    optimize();
    int t=1;
    cin>>t;
    for(int z=1;z<=t;z++){


    do_the_honour();


}
    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:12:18
Judged At
2024-11-11 02:31:13
Judged By
Score
100
Total Time
45ms
Peak Memory
956.0 KiB