QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#877261 | #4869. Brilliant Programmers Show | zxcen | AC ✓ | 583ms | 19400kb | C++14 | 718b | 2025-01-31 20:41:52 | 2025-01-31 20:41:53 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6;
int n;
ll a[N+10],s[N+10];
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int o=0;
while(cin>>n){
if((++o)>=40){
// break;
}
int pos;
for(int i=1;i<=n;++i){
cin>>a[i];
s[i]=s[i-1]+a[i]+1;
if(a[i]>=s[i-1]){
pos=i;
}
}
int cnt=0;
ll sum=0;
for(int i=pos+1;i<=n;++i){
cnt+=(a[i]<=cnt);
sum+=max(0ll,a[i]-cnt);
}
if(sum+s[pos-1]<a[pos]){
cout<<"Bad Rescue\n";
}
else if(sum+s[pos-1]==a[pos]){
cout<<pos<<'\n';
}
else{
cout<<"Unknown\n";
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 583ms
memory: 19400kb
input:
4 1 0 0 3 4 1 0 0 4 8 1 0 0 13 4 3 2 1 8 1 0 0 14 4 3 2 1 2 1 1 10 1 0 1 0 10 0 1 3 0 5 10 1 0 1 0 4 0 1 3 0 5 10 1 0 1 0 3 0 1 3 0 5 20 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 20 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 28 20 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 27 1000000 46 16 21 54 66 41 69 38 81 ...
output:
1 4 Unknown 4 1 Bad Rescue 1 Bad Rescue Bad Rescue 20 Unknown 458699 Bad Rescue Unknown 1 Unknown Unknown Unknown 856109 Bad Rescue 922694 Bad Rescue 846282 Bad Rescue 1 Bad Rescue 10000 Bad Rescue Bad Rescue Unknown 1 2 2 Bad Rescue Unknown Unknown 3 Unknown Unknown Unknown Unknown
result:
ok 41 lines