QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#218156 | #6443. Windblume Festival | Hurrikale# | WA | 59ms | 1496kb | C++14 | 915b | 2023-10-17 19:14:40 | 2023-10-17 19:14:42 |
Judging History
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'