QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637007#8777. Passport StampsTenshi#WA 2ms10084kbC++23616b2024-10-13 05:50:232024-10-13 05:50:24

Judging History

This is the latest submission verdict.

  • [2024-10-13 05:50:24]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 10084kb
  • [2024-10-13 05:50:23]
  • Submitted

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("%d", 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: 5744kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 10084kb

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:

100000

result:

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