# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
295110 |
2020-09-09T13:28:59 Z |
임성재(#5809) |
케이크 (JOI13_cake) |
C++17 |
|
1500 ms |
2036 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n;
deque<int> dQ;
int main() {
fast;
cin >> n;
for(int i=1; i<=n; i++) {
int a;
cin >> a;
dQ.eb(a);
}
for(int i=1; i<=n; i++) {
dQ.eb(dQ[0]);
dQ.pop_front();
int p1 = 0, p2 = n-2;
int c = 1;
ll cnt[2] = {};
cnt[0] = dQ[n-1];
while(p1 <= p2) {
if(dQ[p1] >= dQ[p2]) cnt[c] += dQ[p1++];
else cnt[c] += dQ[p2--];
c = 1 - c;
}
cout << cnt[0] << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
632 KB |
Output is correct |
2 |
Correct |
156 ms |
632 KB |
Output is correct |
3 |
Correct |
148 ms |
504 KB |
Output is correct |
4 |
Correct |
147 ms |
504 KB |
Output is correct |
5 |
Correct |
139 ms |
504 KB |
Output is correct |
6 |
Correct |
151 ms |
504 KB |
Output is correct |
7 |
Correct |
149 ms |
504 KB |
Output is correct |
8 |
Correct |
154 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1583 ms |
2036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |