# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
241377 | 2020-06-24T07:06:58 Z | Mercenary | K개의 묶음 (IZhO14_blocks) | C++14 | 196 ms | 41832 KB |
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 1e5 + 5; const int maxk = 1e2 + 1; const int logn = log2(maxn) + 1; int dp[101][maxn]; int n , k , a[maxn]; int dp1[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } fill_n(&dp[0][0],maxn*maxk,1e9); dp[1][0] = 0; cin >> n >> k; for(int i = 1 ; i <= n ; ++i){ cin >> a[i]; dp[1][i] = max(dp[1][i - 1] , a[i]); } dp[1][0] = 1e9; for(int i = 2 ; i <= k ; ++i){ vector<int> s; for(int j = 1 ; j <= n ; ++j){ int tmp = dp[i - 1][j - 1]; while(s.size() && a[s.back()] <= a[j]){ tmp = min(tmp , dp1[s.back()]); s.pop_back(); } dp1[j] = tmp; dp[i][j] = tmp + a[j]; if(s.size())dp[i][j] = min(dp[i][j] , dp[i][s.back()]); s.pb(j); // cout << dp[i][j] << " "; } } cout << dp[k][n]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 39808 KB | Output is correct |
2 | Correct | 26 ms | 39808 KB | Output is correct |
3 | Correct | 28 ms | 39936 KB | Output is correct |
4 | Correct | 27 ms | 39936 KB | Output is correct |
5 | Correct | 27 ms | 39936 KB | Output is correct |
6 | Correct | 26 ms | 39808 KB | Output is correct |
7 | Correct | 27 ms | 39680 KB | Output is correct |
8 | Correct | 27 ms | 39808 KB | Output is correct |
9 | Correct | 26 ms | 39808 KB | Output is correct |
10 | Correct | 27 ms | 39808 KB | Output is correct |
11 | Correct | 29 ms | 39804 KB | Output is correct |
12 | Correct | 28 ms | 39800 KB | Output is correct |
13 | Correct | 28 ms | 39928 KB | Output is correct |
14 | Correct | 27 ms | 39808 KB | Output is correct |
15 | Correct | 27 ms | 39800 KB | Output is correct |
16 | Correct | 30 ms | 39928 KB | Output is correct |
17 | Correct | 27 ms | 39808 KB | Output is correct |
18 | Correct | 26 ms | 39936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 39808 KB | Output is correct |
2 | Correct | 26 ms | 39936 KB | Output is correct |
3 | Correct | 27 ms | 39808 KB | Output is correct |
4 | Correct | 27 ms | 39808 KB | Output is correct |
5 | Correct | 27 ms | 39808 KB | Output is correct |
6 | Correct | 26 ms | 39808 KB | Output is correct |
7 | Correct | 26 ms | 39936 KB | Output is correct |
8 | Correct | 28 ms | 39808 KB | Output is correct |
9 | Correct | 27 ms | 39800 KB | Output is correct |
10 | Correct | 26 ms | 39808 KB | Output is correct |
11 | Correct | 26 ms | 39808 KB | Output is correct |
12 | Correct | 27 ms | 40064 KB | Output is correct |
13 | Correct | 27 ms | 39936 KB | Output is correct |
14 | Correct | 26 ms | 39808 KB | Output is correct |
15 | Correct | 30 ms | 39800 KB | Output is correct |
16 | Correct | 30 ms | 39928 KB | Output is correct |
17 | Correct | 27 ms | 39808 KB | Output is correct |
18 | Correct | 27 ms | 39808 KB | Output is correct |
19 | Correct | 26 ms | 39808 KB | Output is correct |
20 | Correct | 26 ms | 39800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 39808 KB | Output is correct |
2 | Correct | 27 ms | 39800 KB | Output is correct |
3 | Correct | 27 ms | 39800 KB | Output is correct |
4 | Correct | 26 ms | 39808 KB | Output is correct |
5 | Correct | 27 ms | 39928 KB | Output is correct |
6 | Correct | 27 ms | 39808 KB | Output is correct |
7 | Correct | 27 ms | 39928 KB | Output is correct |
8 | Correct | 27 ms | 39808 KB | Output is correct |
9 | Correct | 27 ms | 39808 KB | Output is correct |
10 | Correct | 26 ms | 39808 KB | Output is correct |
11 | Correct | 30 ms | 39808 KB | Output is correct |
12 | Correct | 27 ms | 39800 KB | Output is correct |
13 | Correct | 27 ms | 39936 KB | Output is correct |
14 | Correct | 26 ms | 39808 KB | Output is correct |
15 | Correct | 26 ms | 39936 KB | Output is correct |
16 | Correct | 28 ms | 39832 KB | Output is correct |
17 | Correct | 27 ms | 39808 KB | Output is correct |
18 | Correct | 27 ms | 39808 KB | Output is correct |
19 | Correct | 27 ms | 39808 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 40064 KB | Output is correct |
2 | Correct | 32 ms | 40312 KB | Output is correct |
3 | Correct | 36 ms | 40568 KB | Output is correct |
4 | Correct | 75 ms | 40568 KB | Output is correct |
5 | Correct | 162 ms | 41464 KB | Output is correct |
6 | Correct | 42 ms | 41464 KB | Output is correct |
7 | Correct | 91 ms | 41336 KB | Output is correct |
8 | Correct | 27 ms | 39800 KB | Output is correct |
9 | Correct | 27 ms | 39808 KB | Output is correct |
10 | Correct | 27 ms | 39808 KB | Output is correct |
11 | Correct | 27 ms | 39808 KB | Output is correct |
12 | Correct | 26 ms | 39936 KB | Output is correct |
13 | Correct | 29 ms | 39936 KB | Output is correct |
14 | Correct | 41 ms | 40064 KB | Output is correct |
15 | Correct | 28 ms | 40064 KB | Output is correct |
16 | Correct | 31 ms | 40064 KB | Output is correct |
17 | Correct | 31 ms | 40312 KB | Output is correct |
18 | Correct | 35 ms | 40576 KB | Output is correct |
19 | Correct | 86 ms | 40576 KB | Output is correct |
20 | Correct | 192 ms | 41336 KB | Output is correct |
21 | Correct | 41 ms | 41336 KB | Output is correct |
22 | Correct | 106 ms | 41336 KB | Output is correct |
23 | Correct | 37 ms | 40952 KB | Output is correct |
24 | Correct | 56 ms | 41336 KB | Output is correct |
25 | Correct | 196 ms | 41336 KB | Output is correct |
26 | Correct | 33 ms | 39936 KB | Output is correct |
27 | Correct | 28 ms | 39936 KB | Output is correct |
28 | Correct | 40 ms | 40056 KB | Output is correct |
29 | Correct | 29 ms | 40056 KB | Output is correct |
30 | Correct | 31 ms | 40064 KB | Output is correct |
31 | Correct | 31 ms | 40312 KB | Output is correct |
32 | Correct | 36 ms | 40704 KB | Output is correct |
33 | Correct | 73 ms | 40704 KB | Output is correct |
34 | Correct | 176 ms | 41832 KB | Output is correct |
35 | Correct | 45 ms | 41720 KB | Output is correct |
36 | Correct | 100 ms | 41788 KB | Output is correct |
37 | Correct | 28 ms | 40056 KB | Output is correct |
38 | Correct | 39 ms | 40064 KB | Output is correct |
39 | Correct | 27 ms | 39928 KB | Output is correct |
40 | Correct | 27 ms | 39936 KB | Output is correct |
41 | Correct | 28 ms | 39936 KB | Output is correct |
42 | Correct | 29 ms | 39808 KB | Output is correct |