QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#257964#5549. Game Showhank55663#WA 1ms7732kbC++142.0kb2023-11-19 14:02:482023-11-19 14:02:49

Judging History

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

  • [2023-11-19 14:02:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7732kb
  • [2023-11-19 14:02:48]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define pdd pair<double,double>
#define pii pair<int,int>
#define pll pair<LL,LL>
#define mp make_pair
#define LL long long
#define ULL unsigned long long
#define sqr(x) ((x)*(x))
#define pi acos(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
    LL prea[400005],preb[400005];
    int a[400005],b[400005];
void solve(int T){
    int n,q;
    scanf("%d %d",&n,&q);

    prea[0]=preb[0]=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
        prea[i]=prea[i-1]+a[i];
    }
    for(int i = 1;i<=n;i++){
        scanf("%d",&b[i+1]);
    }
    b[1]=b[n+1];
    for(int i = 1;i<=n;i++)printf("%d ",b[i]);
    printf("\n");
    for(int i = 1;i<=n;i++){
        preb[i]=preb[i-1]+b[i];
    }
    for(int i = n+1;i<=2*n;i++){
        prea[i]=prea[i-1]+a[i-n];
        preb[i]=preb[i-1]+b[i-n];
    }
    if(prea[n]<0||preb[n]<0){
        for(int i = 0;i<q;i++)printf("flawed\n");
    }
    else{
        for(int i = 1;i<=n;i++){
            if(a[i]+(b[(i%n+1)])<0){
                  for(int i = 0;i<q;i++)printf("flawed\n");
                  return;
            }
        }
        for(int i=0;i<q;i++){
            int s,t;
            scanf("%d %d",&s,&t);
            if(s==t)printf("0\n");
            else {
                LL a,b;
                if(s>t){
                   // t+=n;
                    a=prea[t+n-1]-prea[s-1];
                }
                else{
                    a=prea[t-1]-prea[s-1];
                }
                if(s<t){
                    b=preb[s+n]-preb[t];
                }
                else{
                    b=preb[s]-preb[t];
                }
                printf("%lld\n",min(a,b));
            }
        }
    }
}  
int main(){
    int t=1;
     //scanf("%d",&t);
    for(int i = 1;i<=t;i++){
     //   cerr<<i<<endl;
        solve(i);
    }
}
/*
1227076727
1919786269
1261786217
1924134973
1051246577

*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7732kb

input:

4 4
2 3 -4 3
1 2 7 -1
1 3
3 1
1 4
1 1

output:

-1 1 2 7 
5
-1
-1
0

result:

wrong answer 1st lines differ - expected: '5', found: '-1 1 2 7 '