QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#333738 | #8057. Best Carry Player 4 | ucup-team3160# | WA | 1ms | 3524kb | C++14 | 1.0kb | 2024-02-20 14:28:09 | 2024-02-20 14:28:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void qrun(){
int m;
cin>>m;
long long *p,*q;
p=new long long[m];
q=new long long[m];
for(int i=1;i<=m;i++){
cin>>p[m-1];
}
for(int i=1;i<=m;i++){
cin>>q[m-1];
}
long long cnt=0,tt,sum;
bool ten=false,o=false;
int specp=0;
for(int i=0;i<m;i++){
if(p[i]>0){
specp++;
}
}
int specq=0;
for(int i=0;i<m;i++){
if(p[i]>0){
specp++;
}
}
bool spec=false;
if(specp<=1&&specq<=1){
spec=true;
}
for(int i=0;i<m;i++){
sum+=q[m-1-i];
if(p[i]>=sum){
cnt+=sum;
sum=0;
}
else{
if(o){
cnt+=p[i];
sum-=p[i];
if(p[i]!=0){
ten=true;
}
continue;
}
o=true;//大数第一次溢出
cnt+=p[i];
sum-=p[i];
}
cnt+=tt;
}
if(ten){
cout<<cnt<<endl;
}
else{
if(spec){
cout<<"0\n";
}
else{
cout<<cnt-1<<endl;
}
}
delete[] p;
delete[] q;
return;
}
int main(){
int t;
cin>>t;
for(int i=1;i<=t;i++){
qrun();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3524kb
input:
5 2 1 2 3 4 3 1 0 1 0 1 0 4 1 0 0 1 1 1 1 1 5 123456 114514 1919810 233333 234567 20050815 998244353 0 0 0 10 5 3 5 3 2 4 2 4 1 5 9 9 8 2 4 4 3 5 3 0
output:
2 -1 0 4 -1
result:
wrong answer 1st numbers differ - expected: '5', found: '2'