Submission #623705

# Submission time Handle Problem Language Result Execution time Memory
623705 2022-08-06T10:38:49 Z Ferid20072020 Autići (COCI22_autici) C++14
50 / 50
16 ms 1624 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define ins insert
#define pb push_back
#define MOD 10000
#define oo 1000000001
#define pii pair<int , int>
#define pll pair<ll , ll>
#define pli pair<ll , int>
#define pil pair<int , ll>

int a[100001];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n , x , x1;
    ll min1 = oo , min2 = oo;
    cin >> n;
    if(n == 1){
        cout << 0;
        return 0;
    }
    for(int i=1 ; i<=n ; i++){
        cin >> a[i];
        if(min1 > a[i]){
            min1 = a[i];
            x = i;
        }
    }
    for(int i=1 ; i<=n ; i++){
        if(min2 > a[i] && i != x){
            min2 = a[i];
            x1 = i;
        }
    }
    ll cem = min1 + min2;
    for(int i=1 ; i<=n ; i++){
        if(i != x && i != x1){
            cem += a[i] + min1;
        }
    }
    cout << cem;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:47:24: warning: 'x1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |         if(i != x && i != x1){
      |                      ~~^~~~~
Main.cpp:47:14: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |         if(i != x && i != x1){
      |            ~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 776 KB Output is correct
3 Correct 12 ms 1580 KB Output is correct
4 Correct 10 ms 1492 KB Output is correct
5 Correct 10 ms 1624 KB Output is correct
6 Correct 9 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 776 KB Output is correct
3 Correct 12 ms 1580 KB Output is correct
4 Correct 10 ms 1492 KB Output is correct
5 Correct 10 ms 1624 KB Output is correct
6 Correct 9 ms 1492 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 336 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 5 ms 852 KB Output is correct
22 Correct 16 ms 1616 KB Output is correct
23 Correct 10 ms 1620 KB Output is correct
24 Correct 9 ms 1492 KB Output is correct
25 Correct 10 ms 1612 KB Output is correct
26 Correct 9 ms 1444 KB Output is correct
27 Correct 10 ms 1588 KB Output is correct
28 Correct 9 ms 1492 KB Output is correct
29 Correct 10 ms 1624 KB Output is correct
30 Correct 12 ms 1620 KB Output is correct