# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
258288 | 2020-08-05T16:11:43 Z | karma | K개의 묶음 (IZhO14_blocks) | C++14 | 178 ms | 3068 KB |
#include <bits/stdc++.h> #define pb emplace_back #define ll long long #define fi first #define se second #define mp make_pair //#define int int64_t using namespace std; const int N = int(1e6) + 7; const int inf = 1e9 + 1; typedef pair<ll, ll> pii; struct TNode { int x, y, ans; TNode() {x = y = ans = inf;} TNode(int x, int y): x(x), y(y) { ans = x + y; } void minimize(const TNode& o) { x = min(x, o.x); ans = min(ans, x + y); } } cur; int f[2][N], n, k, a[N]; vector<TNode> v; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define Task "test" if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> k; for(int i = 1; i <= n; ++i) { cin >> a[i]; f[1][i] = max(f[1][i - 1], a[i]); } for(int i = 2; i <= k; ++i) { v.clear(); for(int j = i; j <= n; ++j) { cur = TNode(f[(i & 1) ^ 1][j - 1], a[j]); while(v.size() && v.back().y <= cur.y) { cur.minimize(v.back()); v.pop_back(); } if(v.size()) cur.ans = min(cur.ans, v.back().ans); f[i & 1][j] = cur.ans; v.pb(cur); } } cout << f[k & 1][n]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 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 |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 6 ms | 640 KB | Output is correct |
3 | Correct | 9 ms | 896 KB | Output is correct |
4 | Correct | 52 ms | 1152 KB | Output is correct |
5 | Correct | 150 ms | 2176 KB | Output is correct |
6 | Correct | 15 ms | 2176 KB | Output is correct |
7 | Correct | 75 ms | 2304 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 17 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 512 KB | Output is correct |
16 | Correct | 5 ms | 512 KB | Output is correct |
17 | Correct | 6 ms | 1024 KB | Output is correct |
18 | Correct | 10 ms | 1152 KB | Output is correct |
19 | Correct | 59 ms | 1152 KB | Output is correct |
20 | Correct | 178 ms | 2176 KB | Output is correct |
21 | Correct | 15 ms | 2176 KB | Output is correct |
22 | Correct | 86 ms | 2172 KB | Output is correct |
23 | Correct | 12 ms | 1792 KB | Output is correct |
24 | Correct | 28 ms | 2168 KB | Output is correct |
25 | Correct | 175 ms | 2176 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 16 ms | 640 KB | Output is correct |
29 | Correct | 2 ms | 640 KB | Output is correct |
30 | Correct | 5 ms | 640 KB | Output is correct |
31 | Correct | 9 ms | 1024 KB | Output is correct |
32 | Correct | 11 ms | 1488 KB | Output is correct |
33 | Correct | 54 ms | 1472 KB | Output is correct |
34 | Correct | 157 ms | 3068 KB | Output is correct |
35 | Correct | 17 ms | 3068 KB | Output is correct |
36 | Correct | 77 ms | 3068 KB | Output is correct |
37 | Correct | 2 ms | 512 KB | Output is correct |
38 | Correct | 15 ms | 512 KB | Output is correct |
39 | Correct | 1 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 384 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |