/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 46ms 580.0 KiB
#3 Wrong Answer 83ms 1.336 MiB
#4 Wrong Answer 80ms 1.277 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
  
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        vector<ll>v(n);
        ll s=0;
        for(int i=0;i<n;i++){ cin>>v[i];
                             s+=v[i];
                            }
        ll l=0,r=s,ans=-1;
        while(l<=r)
        {
            ll mid=(l+(r-l)/2);
            if((mid*(mid+1))/2<=s)
            {
                ans=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
        cout<<ans+1<<endl;
    }
        

}

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:14:42
Judged At
2024-11-05 15:14:42
Judged By
Score
10
Total Time
83ms
Peak Memory
1.336 MiB