답안 #672622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
672622 2022-12-17T03:11:49 Z KK_1729 Autići (COCI22_autici) C++17
50 / 50
22 ms 2096 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]+a[0];
    }
    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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 8 ms 980 KB Output is correct
3 Correct 13 ms 980 KB Output is correct
4 Correct 9 ms 980 KB Output is correct
5 Correct 11 ms 1108 KB Output is correct
6 Correct 10 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 224 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 8 ms 980 KB Output is correct
3 Correct 13 ms 980 KB Output is correct
4 Correct 9 ms 980 KB Output is correct
5 Correct 11 ms 1108 KB Output is correct
6 Correct 10 ms 980 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 224 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 7 ms 1224 KB Output is correct
22 Correct 13 ms 2096 KB Output is correct
23 Correct 16 ms 1992 KB Output is correct
24 Correct 16 ms 1940 KB Output is correct
25 Correct 22 ms 2004 KB Output is correct
26 Correct 15 ms 1924 KB Output is correct
27 Correct 17 ms 1992 KB Output is correct
28 Correct 15 ms 1876 KB Output is correct
29 Correct 16 ms 1960 KB Output is correct
30 Correct 14 ms 2004 KB Output is correct