QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720536#5549. Game Showxuxuxuxuxu#WA 14ms3684kbC++141.2kb2024-11-07 13:11:222024-11-07 13:11:27

Judging History

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

  • [2024-11-07 13:11:27]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3684kb
  • [2024-11-07 13:11:22]
  • 提交

answer

#include<cstdio>
#define reg 
int n,q;
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
// #define meow(args...) fprintf(stderr,args)
long long a[400002],b[400002];
int main()
{
    scanf("%d%d",&n,&q);
    long long sum=0;
    bool flag=0;
    for(reg int i=1;i<=n;++i)
    {
        scanf("%lld",a+i);
        sum+=a[i];
        a[i+n]=a[i];
    }
    if(sum<0) flag=1;
    sum=0;
    for(reg int i=1;i<=n;++i)
    {
        scanf("%lld",b+i);
        sum+=b[i];
        b[i+n]=b[i];
        if(a[i]+b[i]<0) flag=1;
    }
    if(sum<0) flag=1;
    if(flag)
    {
        while(q--)
        {
            printf("flawed\n");
        }
        return 0;
    }
    for(reg int i=2;i<=n+n;++i)
    {
        a[i]+=a[i-1];
        b[i]+=b[i-1];
    }
    while(q--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if(x==y) printf("0\n");
        else if(x<y)
        {
            printf("%lld\n",min(a[y-1]+a[x-1],b[x+n-1]-b[y-1]));
            // meow("x<y %lld %lld\n",a[y-1]+a[x-1],b[x+n-1]-b[y-1]);
        }
        else 
        {
            printf("%lld\n",min(b[x-1]-b[y-1],a[y+n-1]-a[x-1]));
            // meow("x>y %lld %lld\n",b[x-1]-b[y-1],a[y+n-1]-a[x-1]);
        }
    }
    return 0;
}

详细

Test #1:

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

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: 3576kb

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: 3580kb

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: 3616kb

input:

3 1
1 2 3
2 3 1
3 3

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3632kb

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: 14ms
memory: 3684kb

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:

0
995988008
722415952
1369922277
1576568268
1127418795
383460539
120442466
643315860
-352554877
39338847
-562838477
349407842
-321953526
-661072387
126473123
403253338
553376758
115095743
-371368628
-897788562
-440671095
-781368782
-975074426
-391551582
-1253790662
-2037459613
-1151174734
-136653686...

result:

wrong answer 313th lines differ - expected: '-273572056', found: '1718403960'