QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#440456 | #8777. Passport Stamps | ANewZhiyangfan# | WA | 4ms | 4608kb | C++14 | 498b | 2024-06-13 19:01:37 | 2024-06-13 19:01:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using E=long long;
int main(){
cin.tie(0)->sync_with_stdio(false);
E n,p;
cin>>n>>p;
vector<E> a(n);
for(int i=0; i<n; i++){
cin>>a[i];
}
vector<E> sfx(n);
sfx[n-1]=a[n-1];
for(int i=n-2; ~i; i--){
sfx[i]=min(a[i],sfx[i+1]);
}
for(int i=0; i<n; i++){
if(p<a[i]){
cout<<i<<endl;
return 0;
}
p-=a[i];
if(i!=n-1) p-=sfx[i+1];
}
cout<<n;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
5 15 1 2 3 4 5
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 4ms
memory: 4608kb
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: 4ms
memory: 4608kb
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'