# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
258265 | 2020-08-05T15:33:57 Z | karma | K개의 묶음 (IZhO14_blocks) | C++14 | 14 ms | 8704 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); } }; 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]; fill_n(&f[0][0], 2 * N, inf); f[0][0] = 0; TNode cur; for(int i = 1; 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()) f[i & 1][j] = v.back().ans; else f[i & 1][j] = inf; f[i & 1][j] = min(f[i & 1][j], cur.ans); v.pb(cur); } } cout << f[k & 1][n]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8192 KB | Output is correct |
2 | Correct | 4 ms | 8208 KB | Output is correct |
3 | Correct | 4 ms | 8192 KB | Output is correct |
4 | Correct | 4 ms | 8192 KB | Output is correct |
5 | Correct | 4 ms | 8192 KB | Output is correct |
6 | Correct | 4 ms | 8192 KB | Output is correct |
7 | Correct | 4 ms | 8192 KB | Output is correct |
8 | Correct | 5 ms | 8192 KB | Output is correct |
9 | Correct | 5 ms | 8192 KB | Output is correct |
10 | Correct | 4 ms | 8192 KB | Output is correct |
11 | Correct | 5 ms | 8192 KB | Output is correct |
12 | Correct | 5 ms | 8192 KB | Output is correct |
13 | Incorrect | 4 ms | 8192 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8192 KB | Output is correct |
2 | Correct | 4 ms | 8192 KB | Output is correct |
3 | Correct | 4 ms | 8192 KB | Output is correct |
4 | Correct | 4 ms | 8192 KB | Output is correct |
5 | Correct | 4 ms | 8192 KB | Output is correct |
6 | Correct | 4 ms | 8192 KB | Output is correct |
7 | Correct | 5 ms | 8192 KB | Output is correct |
8 | Correct | 5 ms | 8192 KB | Output is correct |
9 | Correct | 7 ms | 8192 KB | Output is correct |
10 | Correct | 5 ms | 8192 KB | Output is correct |
11 | Correct | 4 ms | 8192 KB | Output is correct |
12 | Correct | 4 ms | 8192 KB | Output is correct |
13 | Correct | 5 ms | 8192 KB | Output is correct |
14 | Correct | 5 ms | 8192 KB | Output is correct |
15 | Incorrect | 4 ms | 8192 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 8192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8224 KB | Output is correct |
2 | Correct | 10 ms | 8704 KB | Output is correct |
3 | Incorrect | 14 ms | 8704 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |