QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#740820#8777. Passport Stampsydzr00000WA 5ms5456kbC++17644b2024-11-13 11:41:002024-11-13 11:41:01

Judging History

This is the latest submission verdict.

  • [2024-11-13 11:41:01]
  • Judged
  • Verdict: WA
  • Time: 5ms
  • Memory: 5456kb
  • [2024-11-13 11:41:00]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
long long c[100002],sum[100002];
int main(){
    int n;
    long long p;
    scanf("%d %lld",&n,&p);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&c[i]);
        sum[i]=sum[i-1]+c[i];
    }
    c[n+1]=p+1;
    int l=1,r=n+1,ans=-1;
    auto check=[&](const int &pos)->bool
    {
        return (__int128)(c[pos]-1)*pos+sum[pos-1]>p;
    };
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid))
        {
            ans=mid-1;
            r=mid-1;
        }
        else
            l=mid+1;
    }
    printf("%d\n",ans);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3840kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 5ms
memory: 5396kb

input:

100000 559309580160692839
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

84437

result:

ok single line: '84437'

Test #3:

score: -100
Wrong Answer
time: 5ms
memory: 5456kb

input:

100000 890934113082207108
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

100000

result:

wrong answer 1st lines differ - expected: '53636', found: '100000'