QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572264#6443. Windblume Festivalji_114514WA 98ms3640kbC++20622b2024-09-18 13:22:242024-09-18 13:22:25

Judging History

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

  • [2024-09-18 13:22:25]
  • 评测
  • 测评结果:WA
  • 用时:98ms
  • 内存:3640kb
  • [2024-09-18 13:22:24]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 1e6 + 10;
int n, a[N];

void solve()
{
    cin >> n;
    int ok = 0;
    ll res = 0, minv = 1e9 + 7;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        res += abs(a[i]);
        minv = min(minv, llabs(a[i]));
        if (a[i] >= 0)ok |= 1;
        if (a[i] <= 0)ok |= 2;
    }
    if (ok == 3 || n == 1)cout << res << '\n';
    else cout << res - 2 * minv << '\n';

}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t; cin >> t;
    while (t--)solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3640kb

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: 98ms
memory: 3584kb

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'