# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
671587 | 2022-12-13T08:57:46 Z | Alihan_8 | K개의 묶음 (IZhO14_blocks) | C++17 | 1000 ms | 4436 KB |
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long const int N = 1e5+1; int Sparse[20][N]; int get(int l, int r){ int lg = __lg(r-l+1), k = 1 << lg; return max(Sparse[lg][l], Sparse[lg][r-k+1]); } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; vector <int> p(n); for ( auto &i: p ) cin >> i; for ( int i = 1; i <= n; i++ ) Sparse[0][i] = p[i-1]; for ( int i = 1; i < 20; i++ ){ int k = 1 << i-1; for ( int j = 1; j <= n; j++ ){ Sparse[i][j] = max(Sparse[i-1][j], Sparse[i-1][min(n, j+k)]); } } const int inf = 1e15+1; vector <vector<int>> dp(n+1, vector <int> (k+1, inf)); auto chmin = [&](int &l, int r){l = min(l, r);}; dp[0][0] = 0; for ( int i = 1; i <= n; i++ ){ for ( int j = 1; j <= k; j++ ){ for ( int it = 0; it+1 <= i; it++ ){ chmin(dp[i][j], dp[it][j-1]+get(it+1, i)); } } } cout << dp[n][k]; cout << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 0 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 0 ms | 340 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 0 ms | 340 KB | Output is correct |
41 | Correct | 0 ms | 340 KB | Output is correct |
42 | Correct | 0 ms | 340 KB | Output is correct |
43 | Correct | 0 ms | 340 KB | Output is correct |
44 | Correct | 0 ms | 340 KB | Output is correct |
45 | Correct | 0 ms | 340 KB | Output is correct |
46 | Correct | 0 ms | 340 KB | Output is correct |
47 | Correct | 0 ms | 340 KB | Output is correct |
48 | Correct | 0 ms | 340 KB | Output is correct |
49 | Correct | 1 ms | 340 KB | Output is correct |
50 | Correct | 1 ms | 340 KB | Output is correct |
51 | Correct | 1 ms | 468 KB | Output is correct |
52 | Correct | 1 ms | 468 KB | Output is correct |
53 | Correct | 2 ms | 468 KB | Output is correct |
54 | Correct | 2 ms | 468 KB | Output is correct |
55 | Correct | 1 ms | 468 KB | Output is correct |
56 | Correct | 2 ms | 468 KB | Output is correct |
57 | Correct | 2 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 0 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 0 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 0 ms | 340 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 0 ms | 340 KB | Output is correct |
41 | Correct | 0 ms | 340 KB | Output is correct |
42 | Correct | 0 ms | 340 KB | Output is correct |
43 | Correct | 0 ms | 340 KB | Output is correct |
44 | Correct | 0 ms | 340 KB | Output is correct |
45 | Correct | 0 ms | 340 KB | Output is correct |
46 | Correct | 0 ms | 340 KB | Output is correct |
47 | Correct | 0 ms | 340 KB | Output is correct |
48 | Correct | 0 ms | 340 KB | Output is correct |
49 | Correct | 1 ms | 340 KB | Output is correct |
50 | Correct | 1 ms | 340 KB | Output is correct |
51 | Correct | 1 ms | 468 KB | Output is correct |
52 | Correct | 1 ms | 468 KB | Output is correct |
53 | Correct | 2 ms | 468 KB | Output is correct |
54 | Correct | 2 ms | 468 KB | Output is correct |
55 | Correct | 1 ms | 468 KB | Output is correct |
56 | Correct | 2 ms | 468 KB | Output is correct |
57 | Correct | 2 ms | 468 KB | Output is correct |
58 | Execution timed out | 1090 ms | 4436 KB | Time limit exceeded |
59 | Halted | 0 ms | 0 KB | - |