QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691922#6443. Windblume FestivalZero#WA 101ms3672kbC++201.2kb2024-10-31 13:26:062024-10-31 13:26:06

Judging History

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

  • [2024-10-31 13:26:06]
  • 评测
  • 测评结果:WA
  • 用时:101ms
  • 内存:3672kb
  • [2024-10-31 13:26:06]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize (3)
#define de(a) cout << #a << " = " << a << "\n";
#define deg(a) cout << #a << " = " << a << " ";
#define lowbit(x) ((x) & (-x))
#define int long long
#define siz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define PII pair<int, int>
using ll  = long long;
using ull = unsigned long long;
using namespace std;
constexpr ll inf = 1e18;
constexpr int N = 1e6 + 10;
int n, m;
int a[N];

void solve(int Case) {
	cin >> n;
    bool z = 0, f = 0;
    int sum[2]{};
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] >= 0) z = 1, sum[0] += a[i];
        if (a[i] <= 0) f = 1, sum[1] += a[i];
    }
    // deg(sum[0])
    // de(sum[1])
    if (z && f) {
        cout << sum[0] - sum[1] << "\n";
    } else if (z) {
        cout << sum[0] - 2 * *min_element(a + 1, a + n + 1) << "\n";
    } else {
        cout << -sum[1] + 2 * *max_element(a + 1, a + n + 1) << "\n";
    }

}   

signed main() {
    cin.tie(0)->ios::sync_with_stdio(false);
    int T = 1;
    cin >> T; cin.get();

    int Case = 0;
    while (++Case <= T) {
        solve(Case);
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 101ms
memory: 3672kb

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'