QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#720582 | #5549. Game Show | Ufowoqqqo# | WA | 0ms | 5640kb | C++14 | 919b | 2024-11-07 13:22:30 | 2024-11-07 13:22:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e5+5;
ll a[N],b[N];
int main()
{
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
cin>>b[i];
for(int i=1;i<=n;i++)
if(a[i]+b[i]<0)
{
while(q--)
cout<<"flawed"<<endl;
return 0;
}
for(int i=1;i<=n;i++)
{
a[i]+=a[i-1];
b[i]+=b[i-1];
}
while(q--)
{
int s,t;
cin>>s>>t;
if(s==t)cout<<0<<endl;
if(s<t)
{
ll res1=a[t-1]-a[s-1];
ll res2=b[s-1]+b[n]-b[t-1];
cout<<min(res1,res2)<<endl;
}
if(s>t)
{
ll res1=b[s-1]-b[t-1];
ll res2=a[n]-a[s-1]+a[t-1];
cout<<min(res1,res2)<<endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5640kb
input:
4 4 2 3 -4 3 1 2 7 -1 1 3 3 1 1 4 1 1
output:
5 -1 -1 0
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 3 1 2 -3 4 4 -3 2 1 1 1 2 4 3 1
output:
flawed flawed flawed
result:
ok 3 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 5576kb
input:
6 2 -6 8 -3 5 -9 4 9 -2 8 -4 12 -1 2 6 3 3
output:
1 0
result:
wrong answer 1st lines differ - expected: 'flawed', found: '1'