QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#333744 | #8057. Best Carry Player 4 | ucup-team3160# | WA | 146ms | 3608kb | C++14 | 1.3kb | 2024-02-20 14:40:46 | 2024-02-20 14:40:47 |
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+1];
q=new long long[m+1];
for(int i=1;i<=m;i++){
cin>>p[i-1];
}
for(int i=1;i<=m;i++){
cin>>q[i-1];
}
p[0]+=1e16;
q[0]+=1e16;
long long cnt=0,sum=0;
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];
//cout<<"进行到第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<endl;
if(p[i]>=sum){
cnt+=sum;
sum=0;
}
else{
if(o){
cnt+=p[i];
sum-=p[i];
if(p[i]!=0){
ten=true;
}
}
else{
o=true;//大数第一次溢出
cnt+=p[i];
sum-=p[i];
}
}
//cout<<"进行完第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<endl;
}
if(ten){
//cout<<"输出:"<<cnt<<endl;
cout<<cnt<<endl;
}
else{
if(spec){
//cout<<"输出"<<"0\n";
cout<<"0\n";
}
else{
//cout<<"输出"<<cnt-1<<endl;
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: 100
Accepted
time: 0ms
memory: 3532kb
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:
5 1 2 467900 29
result:
ok 5 number(s): "5 1 2 467900 29"
Test #2:
score: -100
Wrong Answer
time: 146ms
memory: 3608kb
input:
100000 5 0 1 1 1 1 0 0 1 0 0 5 0 0 0 0 0 1 1 1 0 0 5 0 0 2 1 1 0 2 1 0 1 5 0 0 0 0 0 1 2 1 0 0 5 0 1 0 1 1 0 0 1 1 1 5 2 0 0 0 1 1 0 0 0 3 5 2 0 0 1 1 0 2 1 1 1 5 0 0 0 0 2 0 0 0 0 1 5 0 0 0 0 0 0 1 1 0 0 5 4 0 0 0 0 0 0 0 1 0 5 0 0 0 0 1 2 1 1 0 0 5 0 2 3 0 0 0 0 0 1 0 5 1 1 1 0 1 1 0 1 0 1 5 0 0 0...
output:
1 -1 4 -1 4 3 3 2 -1 -1 1 0 2 0 3 0 0 -1 -1 0 0 0 3 0 4 1 -1 2 3 2 1 4 0 -1 2 0 0 0 0 -1 0 3 5 3 1 2 1 -1 0 2 2 1 -1 3 0 2 1 1 0 0 -1 4 1 1 2 2 -1 3 3 -1 1 -1 1 -1 0 1 1 2 0 2 4 -1 1 5 -1 1 1 0 0 -1 2 1 3 -1 1 0 4 3 2 0 2 2 1 0 3 0 0 -1 0 -1 1 -1 3 2 2 -1 1 0 0 0 1 -1 0 2 4 1 2 3 2 2 2 -1 1 -1 0 2 3...
result:
wrong answer 1st numbers differ - expected: '2', found: '1'