# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
872716 | 2023-11-13T15:31:43 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("MAXK.inp", "r")) { freopen("MAXK.inp", "r", stdin); freopen("MAXK.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; ll minF = 1e18; FOR(i, 1, n){ while(q.size() && a[q.top().first] <= a[i]){ minF = min(minF, q.top().second); q.pop(); } f[i][j] = minF + a[i]; q.push({i, f[i][j - 1]}); } } 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 | 1 ms | 2396 KB | Output is correct |
5 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Correct | 1 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 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
6 | 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 | 1 ms | 2396 KB | Output is correct |
5 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
6 | 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 | 1 ms | 2396 KB | Output is correct |
5 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |