QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#333778 | #8057. Best Carry Player 4 | ucup-team3160# | WA | 142ms | 3592kb | C++14 | 1.7kb | 2024-02-20 15:29:32 | 2024-02-20 15:29:32 |
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]+=1e10;
long long cnt=0,sum=0,pcnt=0,qcnt=0;
bool ten=false,o=false,ob=false,obb=false;
int specp=0;
for(int i=0;i<m;i++){
pcnt+=p[i];
if(p[i]>0){
specp++;
}
}
int specq=0;
for(int i=0;i<m;i++){
qcnt+=q[i];
if(p[i]>0){
specp++;
}
}
if(pcnt>qcnt){
q[0]+=(pcnt-qcnt);
}
else{
p[0]+=(qcnt-pcnt);
}
bool spec=false;
if(specp<=1&&specq<=1){
spec=true;
}
for(int i=0;i<m;i++){
sum+=q[m-1-i];
// if(i==m-1){
// sum=1e10;
// }
// cout<<"进行到第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<"o:"<<o<<"ob:"<<ob<<"obb:"<<obb<<"ten:"<<ten<<endl;
if(sum>0&&p[i]>0){
ob=true;
}
if(p[i]>sum&&obb){
ten=true;
}
if(p[i]>=sum){
if(sum!=0&&o){
ten=true;
}
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];
}
}
if(ob){
obb=true;
}
// cout<<"进行完第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<"o:"<<o<<"ob:"<<ob<<"obb:"<<obb<<"ten:"<<ten<<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>0 ? cnt-1 : cnt)<<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: 3592kb
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: 142ms
memory: 3552kb
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:
2 0 4 0 3 3 3 2 0 0 1 1 3 0 3 0 0 0 0 0 0 0 4 0 4 1 0 2 3 3 1 5 0 0 2 0 0 1 1 0 0 3 5 3 2 2 2 0 1 2 2 2 0 3 0 2 1 1 0 1 0 4 1 1 2 2 0 3 3 0 2 0 1 0 0 1 1 2 0 3 4 0 2 5 0 2 1 0 0 0 3 2 3 0 2 0 4 3 3 0 2 2 0 1 3 1 1 0 0 0 1 0 3 2 2 0 2 1 1 0 1 0 0 2 4 1 3 3 2 2 2 0 2 0 0 2 3 1 3 1 0 2 2 3 0 1 2 0 1 1 ...
result:
wrong answer 63rd numbers differ - expected: '0', found: '1'