QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#604310 | #6443. Windblume Festival | LJY_ljy | WA | 55ms | 3848kb | C++11 | 1.0kb | 2024-10-02 09:22:42 | 2024-10-02 09:22:43 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
const long long MAXN = 1e6 + 10;
inline long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
long long n, a[MAXN];
int main() {
long long t = read();
for (long long u = 1; u <= t; u++) {
n = read();
bool flag = false;
for (long long i = 1; i <= n; i++) {
a[i] = read();
if (a[i] <= 0) flag = true;
}
if (flag) {
long long ans = 0;
for (long long i = 1; i <= n; i++) {
ans += abs(a[i]);
}
printf("%lld\n", ans);
} else if (n > 1) {
sort(a + 1, a + 1 + n);
long long ans = 0;
for (long long i = 2; i <= n; i++) ans += a[i];
ans -= a[1];
printf("%lld\n", ans);
} else {
printf("%lld\n", a[1]);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
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: 55ms
memory: 3772kb
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 0 1 2 2 1 2 2 0 1 1 1 2 2 2 1 1 2 0 2 2 2 1 0 1 0 1 2 2 1 2 1 1 0 1 1 1 0 2 2 1 0 2 0 ...
result:
wrong answer 2nd numbers differ - expected: '-2', found: '2'