QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637011#8777. Passport StampsTenshi#WA 5ms10824kbC++23618b2024-10-13 05:55:132024-10-13 05:55:14

Judging History

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

  • [2024-10-13 05:55:14]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:10824kb
  • [2024-10-13 05:55:13]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int N=5e6+5;

#define int long long

int c;
int w[N];
int s[N];

bool ok(int t){
    if(!t) return true;

    __int128 fir=__int128(t-1)*(w[t]-1);
    if(fir>1e18) return false;
    int sec=fir+s[t-1];
    if(sec>1e18) return false;
    return c-sec>=w[t];
}

signed main(){
    int n; cin>>n>>c;
    for(int i=1; i<=n; i++) scanf("%lld", w+i), s[i]=min((int)2e18, s[i-1]+w[i]);

    int l=0, r=n;
    while(l<r){
        int mid=l+r+1>>1;
        if(ok(mid)) l=mid;
        else r=mid-1;
    }
    cout<<l<<endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5624kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

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

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

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'