QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218156#6443. Windblume FestivalHurrikale#WA 59ms1496kbC++14915b2023-10-17 19:14:402023-10-17 19:14:42

Judging History

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

  • [2023-10-17 19:14:42]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:1496kb
  • [2023-10-17 19:14:40]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int Read()
{
    int Output=0,W=1;
    char Input=getchar();
    while(Input<'0'||Input>'9')
    {
        if(Input=='-')W=-1;
        Input=getchar();
    }
    while(Input>='0'&&Input<='9')
    {
        Output=Output*10+Input-'0';
        Input=getchar();
    }
    return Output*W;
}
ll ABS(ll X)
{
    return (X>0?X:-X);
}
const int Inf=1e9+1;
int T;
int N;
ll Total;
ll Max=-Inf,Min=Inf;
int main()
{
    T=Read();
    while(T--)
    {
        Total=0,Min=Inf,Max=-Inf;
        N=Read();
        for(int i=1;i<=N;++i)
    {
        ll X=Read();
        Min=min(X,Min);
        Max=max(X,Max);
        Total+=ABS(X);
    }
    if(Min<0&&Max>0)printf("%lld",Total);
    else if(Max<=0)printf("%lld",Total-(ABS(Max)<<1));
    else printf("%lld",Total-Min*2);
    putchar('\n');
    }
}

詳細信息

Test #1:

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

input:

5
4
1 -3 2 -4
11
91 66 73 71 32 83 72 79 84 33 93
12
91 66 73 71 32 83 72 79 84 33 33 93
13
91 66 73 71 32 83 72 79 84 33 33 33 93
1
0

output:

10
713
746
779
0

result:

ok 5 number(s): "10 713 746 779 0"

Test #2:

score: -100
Wrong Answer
time: 59ms
memory: 1496kb

input:

1000000
1
2
1
-2
1
1
1
-1
1
2
1
1
1
2
1
-2
1
-2
1
2
1
1
1
1
1
2
1
2
1
2
1
-2
1
-2
1
0
1
2
1
1
1
-1
1
0
1
-2
1
0
1
1
1
1
1
-2
1
-2
1
2
1
1
1
2
1
1
1
1
1
0
1
2
1
0
1
-1
1
-1
1
-2
1
-2
1
0
1
-2
1
0
1
1
1
-1
1
2
1
0
1
-2
1
-2
1
0
1
1
1
-1
1
-2
1
-1
1
0
1
-1
1
-1
1
-1
1
-1
1
1
1
2
1
0
1
0
1
-2
1
2
1
2
1
...

output:

-2
-2
-1
-1
-2
-1
-2
-2
-2
-2
-1
-1
-2
-2
-2
-2
-2
0
-2
-1
-1
0
-2
0
-1
-1
-2
-2
-2
-1
-2
-1
-1
0
-2
0
-1
-1
-2
-2
0
-2
0
-1
-1
-2
0
-2
-2
0
-1
-1
-2
-1
0
-1
-1
-1
-1
-1
-2
0
0
-2
-2
-2
-1
-2
-2
-1
-2
-1
-2
-2
-1
-1
0
-2
0
0
0
-1
-1
-2
-1
-1
0
-2
-1
-2
-1
-1
0
-1
-2
-2
-1
-1
0
-2
-2
-2
-1
0
-1
0
-1
...

result:

wrong answer 1st numbers differ - expected: '2', found: '-2'