이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "
#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back
// Binary Search, maybe
void solve()
{
ll n;
cin >> n;
ll t[n + 1];
FOR(i, 1, n + 1)
cin >> t[i];
// ll dp[n + 1][n + 1];
// dp[i][j] = min time taken for the first i customers if they are in j groups
if(n == 1) {
cout << t[1] << nl;
return;
}
if(n == 2) {
ll op1 = t[1] + t[1] + t[2];
ll op2 = max(t[1], t[2]) * 2;
cout << min(op1, op2) << nl;
return;
}
ll op1 = max({t[1], t[2], t[3]}) * 3;
ll op2 = t[1] + (t[1] + max(t[2], t[3])) * 2;
ll op3 = max(t[1], t[2]) * 2 + (max(t[1], t[2]) + t[3]);
ll op4 = t[1] + t[1] + t[2] + t[1] + t[2] + t[3];
cout << min({op1, op2, op3, op4}) << nl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
# | 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... |