QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#740441#8777. Passport Stampsydzr00000WA 5ms5384kbC++17640b2024-11-13 09:56:332024-11-13 09:56:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 09:56:33]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:5384kb
  • [2024-11-13 09:56:33]
  • 提交

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]*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;
}

詳細信息

Test #1:

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

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 2ms
memory: 5380kb

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: 5384kb

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'