Submission #672620

# Submission time Handle Problem Language Result Execution time Memory
672620 2022-12-17T03:09:25 Z KK_1729 Autići (COCI22_autici) C++17
10 / 50
17 ms 2004 KB
#include <bits/stdc++.h>
using namespace std;

// Macros
#define int long long
#define double long long double
#define pb push_back
#define str string
#define vi vector<int>
#define mp make_pair
#define mi map<int, int>
#define umi unordered_map<int, int>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define all(a) a.begin(), a.end()
#define endl "\n"
int mod = 1000000007;
// int mod = 3;
template<typename T>
void printMap(T a){
    cout << "{ ";
    for (auto x: a){
        cout << x.first << ": " << x.second << " ";
    }
    cout << "}" << endl;
}
int twopower(int x){
    int ans = 0;
    if (x == 0) return 0;
    while (x%2 == 0){
        ans++;
        x /= 2;
    }
    return ans;
}
template<typename T>
void printVector(T a){
    for (auto x: a){
        cout << x << " ";
    }
    cout << endl;
}
int max_element(vi a){
    int m = -1e17;
    for (auto x: a){
        m = max(m, x);
    }
    return m;
}
int max(int x, int y){
    if (x > y) return x;
    else return y;
}


int sum(vector<int> a){
    int ans = 0;
    for (auto x: a) ans += x;
    return ans;
}
int min(int x, int y){
    if (x < y) return x;
    else return y;
}
bool comp(int n1, int d1, int n2, int d2){ // returns true if fraction1 is smaller than fraction2

    return (n1*d2 < n2*d1);
}
bool equal(int n1, int d1, int n2, int d2){ // returns true if fraction1 is smaller than fraction2

    return (n1*d2 == n2*d1);
}






void solve(){
    // cout << "i";
    int n; cin >> n;
    vector<int> a(n);
    FOR(i,0,n) cin >> a[i];
    sort(all(a));
    // cout << "i";
    int ans = 0;
    if (n == 1){
        cout << 0 << endl;
        return;
    }
    FOR(i,0,n-2){
        ans += a[i]*2;
    }
    FOR(i,n-2,n){
        ans += a[i];
    }
    cout << ans << endl;
}
int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);
    // freopen("factory.in", "r", stdin);
    // freopen("factory.out", "w", stdout);
    int t = 1;
    // cout << "a";
    // int t; cin >> t;
    while (t--){
        // cout << "a";
        // str inp; cin >> inp;
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1236 KB Output is correct
3 Correct 17 ms 1996 KB Output is correct
4 Correct 11 ms 1848 KB Output is correct
5 Correct 16 ms 2004 KB Output is correct
6 Correct 10 ms 1816 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 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1236 KB Output is correct
3 Correct 17 ms 1996 KB Output is correct
4 Correct 11 ms 1848 KB Output is correct
5 Correct 16 ms 2004 KB Output is correct
6 Correct 10 ms 1816 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 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -