이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
#define nl "\n"
#define fr first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()
#define fur(i, a, b) for(ll i = a; i <= b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= b; --i)
#define pv(x) for(auto k : x){cout << k << " ";} cout << nl
ll n;
vl t;
void solve(){
// n <= 3
if (n == 1){
cout << t[1] << nl;
}else if (n == 2){
cout << min(t[1] + t[1] + t[2], max(t[1], t[2]) * 2);
}else{
ll a = t[1];
ll b = t[2];
ll c = t[3];
// a b c
ll op1 = a + (a + b) + (a + b + c);
// ab c
ll op2 = (max(a, b) * 2) + max(a, b) + c;
// a bc
ll op3 = a + (a + max(b, c)) * 2;
// abc
ll op4 = max(a, max(b, c)) * 3;
cout << min(min(op1, op2), min(op3, op4));
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
t.resize(n + 1);
fur(i, 1, n)
cin >> t[i];
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |