답안 #320677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320677 2020-11-09T13:45:54 Z vishesh312 Discharging (NOI20_discharging) C++17
20 / 100
145 ms 8300 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f  first
#define s  second

#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()

using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_multiset = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;  

ll binpow(ll a, ll b) {
    //a = a % mod;
    ll res = 1;
    while ( b > 0) {
        if (b&1) {
            res = (a*res);//%mod;
        }
        a = (a*a);//%mod;
        b >>= 1;
    }
    return res;
}

void solve(int tc) {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &x : v) cin >> x;
    if (n<=3) {
        if (n==1) {
            cout << v[0] << '\n';
            return;
        }
        if (n==2) {
            cout << min(max(v[0], v[1])*2, 2*v[0] + v[1]) << '\n';
            return;
        }
        if (n==3) {
            cout << min({*max_element(all(v))*3, v[0]*3+v[1]*2+v[2], max(v[0], v[1])*3+v[2], v[0]*3+max(v[1], v[2])*2}) << '\n';
            return;
        }
    } else {
        cout << (ll)n*v[0] << '\n';
    }
}

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

    int tc = 1;
    //cin >> tc;

    for (int i = 1; i <= tc; ++i) {
        solve(i);
    }

    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 8172 KB Output is correct
2 Correct 115 ms 8300 KB Output is correct
3 Correct 112 ms 8172 KB Output is correct
4 Correct 134 ms 8172 KB Output is correct
5 Correct 145 ms 8172 KB Output is correct
6 Correct 121 ms 8172 KB Output is correct
7 Correct 123 ms 8172 KB Output is correct
8 Correct 124 ms 8172 KB Output is correct
9 Correct 118 ms 8172 KB Output is correct
10 Correct 113 ms 8172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Incorrect 1 ms 364 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Incorrect 1 ms 364 KB Output isn't correct
16 Halted 0 ms 0 KB -