QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#637011 | #8777. Passport Stamps | Tenshi# | WA | 5ms | 10824kb | C++23 | 618b | 2024-10-13 05:55:13 | 2024-10-13 05:55:14 |
Judging History
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;
}
详细
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'