QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333755 | #8057. Best Carry Player 4 | ucup-team3160# | WA | 133ms | 3672kb | C++14 | 1.4kb | 2024-02-20 14:54:47 | 2024-02-20 14:54:48 |
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;
bool ten=false,o=false,ob=false,obb=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(i==m-1){
sum=1e10;
}
//cout<<"进行到第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<endl;
if(sum>0&&p[i]>0){
ob=true;
}
if(p[i]>sum&&obb){
ten=true;
}
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];
}
}
if(ob){
obb;
}
//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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
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: 133ms
memory: 3568kb
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'