Submission #1055767

# Submission time Handle Problem Language Result Execution time Memory
1055767 2024-08-13T05:08:29 Z manhlinh1501 Autići (COCI22_autici) C++17
50 / 50
11 ms 1756 KB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 1e5 + 5;

int N;
int a[MAXN];
i64 ans = 0;

signed main() {
#define TASK "code"

    if (fopen(TASK ".inp", "r")) {
        freopen(TASK ".inp", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    if(N == 1) return cout << 0, 0;
    for(int i = 1; i <= N; i++) cin >> a[i];
    sort(a + 1, a + N + 1);
    i64 ans = accumulate(a + 1, a + N + 1, 0LL) + 1LL * a[1] * (N - 2);
    cout << ans;
    return (0 ^ 0);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 832 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 6 ms 1524 KB Output is correct
5 Correct 6 ms 1492 KB Output is correct
6 Correct 6 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 472 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 832 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 6 ms 1524 KB Output is correct
5 Correct 6 ms 1492 KB Output is correct
6 Correct 6 ms 1516 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 472 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 464 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 816 KB Output is correct
22 Correct 6 ms 1756 KB Output is correct
23 Correct 6 ms 1628 KB Output is correct
24 Correct 9 ms 1724 KB Output is correct
25 Correct 11 ms 1744 KB Output is correct
26 Correct 10 ms 1628 KB Output is correct
27 Correct 10 ms 1628 KB Output is correct
28 Correct 10 ms 1684 KB Output is correct
29 Correct 10 ms 1644 KB Output is correct
30 Correct 6 ms 1628 KB Output is correct