QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583485 | #5549. Game Show | surenjamts# | RE | 4ms | 3624kb | C++20 | 1.1kb | 2024-09-22 20:10:57 | 2024-09-22 20:10:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 145;
int nz[N+5], nb[N+5];
signed main(){
int n, q, s, t, sum1 = 0, sum2=0;
int a[N+5], b[N+5];
cin >> n >> q;
for(int i = 1; i <= n; i ++ ){
cin >> a[i];
sum1+= a[i];
}
bool flawed = false;
for(int i = 1; i <= n; i ++ ){
cin >> b[i];
sum2+= b[i];
if( a[i]+b[i] < 0 ){
flawed = true;
}
}
if( sum1 < 0 || sum2 < 0 ){
flawed = 1;
}
for(int i = 2; i <= n; i ++ ){
nz[ i ] = nz[i-1] + a[i-1];
}
nz[n+1] = nz[n] + a[n];
for(int i = n; i >= 1; i -- ){
nb[ i ] = nb[i+1] + b[i];
}
// cout << "nar zuv:";
// for(int i = 1; i <= n+1; i ++ ){
// cout << nz[i] << " ";
// }
// cout << "\n";
// cout << "nar buruu:";
// for(int i = 1; i <= n+1; i ++ ){
// cout << nb[i] << " ";
// }
// cout << "\n";
while( q -- ){
cin >> s >> t;
if( flawed ){
cout << "flawed\n";
continue;
}
if( s < t ){
cout << min( nz[t]-nz[s], nb[1]-nb[s]+nb[t] ) << "\n";
}else{
cout << min( nb[t]-nb[s], nz[n+1]-nz[s]+nz[t] ) << "\n";
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3564kb
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: 0
Accepted
time: 0ms
memory: 3624kb
input:
6 2 -6 8 -3 5 -9 4 9 -2 8 -4 12 -1 2 6 3 3
output:
flawed flawed
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
3 1 1 2 3 2 3 1 3 3
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 4ms
memory: 3576kb
input:
119 14161 -471334480 -303286501 -823503521 204458352 428751472 -685555801 -315724979 454499825 326635838 274924560 623877126 -41230889 829726183 -901302108 -414222870 430105197 -163781582 -654097302 -785578511 634678229 -53714045 466578268 -156361557 31276696 778119895 744605022 -686693025 368251457...
output:
flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed flawed...
result:
ok 14161 lines
Test #6:
score: -100
Runtime Error
input:
310 96100 995988008 -273572056 647506325 206645991 -449149473 -743958256 -263018073 522873394 -995870737 391893724 -602177324 912246319 -671361368 -339118861 787545510 276780215 150123420 -438281015 -486464371 -526419934 457117467 -340697687 -193705644 583522844 -862239080 -783668951 886284879 -2153...