/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 31ms 576.0 KiB
#3 Accepted 42ms 788.0 KiB
#4 Accepted 21ms 832.0 KiB
#5 Accepted 23ms 788.0 KiB
#6 Accepted 21ms 788.0 KiB
#7 Accepted 21ms 952.0 KiB
#8 Accepted 21ms 788.0 KiB
#9 Accepted 48ms 788.0 KiB
#10 Accepted 21ms 796.0 KiB
#11 Accepted 22ms 788.0 KiB
#12 Accepted 21ms 792.0 KiB
#13 Accepted 21ms 788.0 KiB
#14 Accepted 44ms 788.0 KiB
#15 Accepted 20ms 832.0 KiB
#16 Accepted 21ms 788.0 KiB
#17 Accepted 21ms 788.0 KiB
#18 Accepted 20ms 944.0 KiB
#19 Accepted 20ms 788.0 KiB
#20 Accepted 21ms 948.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-05 15:12:18
Judged By
Score
100
Total Time
48ms
Peak Memory
952.0 KiB