# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
872723 | 2023-11-13T15:49:20 Z | vjudge1 | K개의 묶음 (IZhO14_blocks) | C++17 | 1 ms | 2396 KB |
#include <bits/stdc++.h> #define FOR(i, l, r) for(int i = (l); i <= (r); i ++) #define ll long long #define MASK(j) (1LL << (j)) #define int ll using namespace std; int f[100001][101]; int a[200000]; signed main() { if(fopen("blocks.in", "r")) { freopen("blocks.in", "r", stdin); freopen("blocks.out", "w", stdout); } if(fopen("a.inp", "r")) { freopen("a.inp", "r", stdin); freopen("a.out", "w", stdout); } int n, k; cin >> n >> k; FOR(i, 1, n) cin >> a[i]; ll mx = 0; FOR(i, 1, n) mx = max(mx, a[i]), f[i][1] = mx; FOR(j, 2, k){ stack <pair <int,int>> q; FOR(i, j, n){ ll minF = f[i - 1][j - 1]; while(q.size() && a[q.top().first] <= a[i]){ minF = min(minF, q.top().second); q.pop(); } f[i][j] = minF + a[i]; if(q.size()) f[i][j] = min(f[i][j], q.top().second + a[q.top().first]); q.push({i, minF}); } } cout << f[n][k]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 0 ms | 2392 KB | Output is correct |
8 | Correct | 0 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2392 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2392 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 0 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 0 ms | 2396 KB | Output is correct |
8 | Correct | 0 ms | 2396 KB | Output is correct |
9 | Correct | 0 ms | 2396 KB | Output is correct |
10 | Correct | 0 ms | 2396 KB | Output is correct |
11 | Correct | 0 ms | 2396 KB | Output is correct |
12 | Correct | 0 ms | 2396 KB | Output is correct |
13 | Correct | 0 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 0 ms | 2392 KB | Output is correct |
8 | Correct | 0 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2392 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 0 ms | 2392 KB | Output is correct |
8 | Correct | 0 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2392 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |