QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720529#5549. Game ShowinfCraft#WA 10ms7736kbC++171.5kb2024-11-07 13:09:462024-11-07 13:09:46

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 13:09:46]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:7736kb
  • [2024-11-07 13:09:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define fori(x, y) for (int i=(x);i<=(y);++i)
#define forj(x, y) for (int j=(x);j<=(y);++j)
#define fork(x, y) for (int k=(x);k<=(y);++k)
const int N = 1e6 +10;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define debug(x) cerr << #x << " = " << x << endl
int a[N];
int b[N];
int prea[N],preb[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin>>n>>q;
    int flag = 0;
    for(int i = 1;i<=n;i++){
        cin>>a[i];
        prea[i] = prea[i-1]+a[i];
    }
    for(int i = 1;i<=n;i++){
        a[i+n] = a[i];
        prea[i+n] = prea[i+n-1]+a[i+n];
    }
    for(int i = 1;i<=n;i++){
        cin>>b[i];
        preb[i] = preb[i-1]+b[i];
    }
    for(int i = 1;i<=n;i++){
        b[i+n] = b[i];
        if(b[i]+a[i]<0){
            flag = 1;
        }
        preb[i+n] = preb[i+n-1]+b[i+n];
    }
    if(prea[n]<0 || preb[n]<0) flag = 1;
    int s,t;
    while(q--){
        cin>>s>>t;
        if(flag){
            cout<<"flawed"<<'\n';
            continue;
        }
        if(s==t){
            cout<<0<<'\n';
            continue;
        }
        if(s<t){
            int minn = prea[t-1] - prea[s-1]; 
            minn = min(minn,preb[s+n-1]- preb[t-1]);
            cout<<minn<<'\n';
            continue;
        }
        int minn = prea[t+n-1] - prea[s-1];
        minn = min(minn,preb[s-1] - preb[t-1]);
        cout<<minn<<'\n';

    }



    
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7648kb

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: 1ms
memory: 7716kb

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: 1ms
memory: 7660kb

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: 1ms
memory: 7736kb

input:

3 1
1 2 3
2 3 1
3 3

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 2ms
memory: 7724kb

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
Wrong Answer
time: 10ms
memory: 7728kb

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...

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:

wrong answer 1st lines differ - expected: '0', found: 'flawed'