# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
716156 | 2023-03-29T06:36:47 Z | ktkerem | K개의 묶음 (IZhO14_blocks) | C++17 | 234 ms | 84736 KB |
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> typedef long long ll; typedef long double ld; typedef __int128 vll; typedef long long ftyp; typedef std::complex<ftyp> vec; #define llll std::pair<ll , ll> #define pb push_back #define fi first #define sec second #define cx real #define cy imag #define all(a) a.begin() , a.end() #define debug std::cout << "!!ALERT ALERT!!" << std::endl; const ll limit = 1e15+7; const ll sus = 1e5+5; std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); ll n , m;std::vector<ll> ar; ll dp[105][sus]; void solve(){ std::cin >> n >> m; ar.resize(n+5); memset(dp , 0x3f , sizeof(dp)); for(ll i = 1;n>=i;i++){ std::cin >> ar[i]; } dp[1][1] = ar[1]; for(ll i = 2;n>=i;i++){ dp[1][i] = std::max(dp[1][i-1] , ar[i]); } for(ll k = 2;m>=k;k++){ std::stack<ll> s1 , s2; for(ll j = 1;n>=j;j++){ ll ff = dp[k-1][j-1]; while(!s1.empty() && s1.top() < ar[j]){ ff = std::min(ff , s2.top()); s1.pop(); s2.pop(); } if(s1.empty() || ff + ar[j] < s1.top() + s2.top()){ s1.push(ar[j]); s2.push(ff); } if(j >= k){ dp[k][j] = s1.top() + s2.top(); } } } std::cout << dp[m][n]; return;/**/ } int main(){ ll t = 1; //std::cin >> t; while(t--){ solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 82376 KB | Output is correct |
2 | Correct | 32 ms | 82464 KB | Output is correct |
3 | Correct | 36 ms | 82428 KB | Output is correct |
4 | Correct | 38 ms | 82480 KB | Output is correct |
5 | Correct | 31 ms | 82436 KB | Output is correct |
6 | Correct | 32 ms | 82540 KB | Output is correct |
7 | Correct | 36 ms | 82368 KB | Output is correct |
8 | Correct | 32 ms | 82380 KB | Output is correct |
9 | Correct | 32 ms | 82468 KB | Output is correct |
10 | Correct | 32 ms | 82376 KB | Output is correct |
11 | Correct | 39 ms | 82380 KB | Output is correct |
12 | Correct | 33 ms | 82484 KB | Output is correct |
13 | Correct | 34 ms | 82432 KB | Output is correct |
14 | Correct | 32 ms | 82480 KB | Output is correct |
15 | Correct | 32 ms | 82476 KB | Output is correct |
16 | Correct | 31 ms | 82384 KB | Output is correct |
17 | Correct | 38 ms | 82432 KB | Output is correct |
18 | Correct | 34 ms | 82484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 82484 KB | Output is correct |
2 | Correct | 37 ms | 82452 KB | Output is correct |
3 | Correct | 32 ms | 82416 KB | Output is correct |
4 | Correct | 32 ms | 82372 KB | Output is correct |
5 | Correct | 33 ms | 82388 KB | Output is correct |
6 | Correct | 34 ms | 82420 KB | Output is correct |
7 | Correct | 34 ms | 82384 KB | Output is correct |
8 | Correct | 33 ms | 82408 KB | Output is correct |
9 | Correct | 32 ms | 82388 KB | Output is correct |
10 | Correct | 32 ms | 82396 KB | Output is correct |
11 | Correct | 34 ms | 82384 KB | Output is correct |
12 | Correct | 31 ms | 82488 KB | Output is correct |
13 | Correct | 33 ms | 82384 KB | Output is correct |
14 | Correct | 30 ms | 82440 KB | Output is correct |
15 | Correct | 39 ms | 82380 KB | Output is correct |
16 | Correct | 35 ms | 82472 KB | Output is correct |
17 | Correct | 37 ms | 82592 KB | Output is correct |
18 | Correct | 34 ms | 82476 KB | Output is correct |
19 | Correct | 33 ms | 82476 KB | Output is correct |
20 | Correct | 32 ms | 82384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 82376 KB | Output is correct |
2 | Correct | 32 ms | 82464 KB | Output is correct |
3 | Correct | 36 ms | 82428 KB | Output is correct |
4 | Correct | 38 ms | 82480 KB | Output is correct |
5 | Correct | 31 ms | 82436 KB | Output is correct |
6 | Correct | 32 ms | 82540 KB | Output is correct |
7 | Correct | 36 ms | 82368 KB | Output is correct |
8 | Correct | 32 ms | 82380 KB | Output is correct |
9 | Correct | 32 ms | 82468 KB | Output is correct |
10 | Correct | 32 ms | 82376 KB | Output is correct |
11 | Correct | 39 ms | 82380 KB | Output is correct |
12 | Correct | 33 ms | 82484 KB | Output is correct |
13 | Correct | 34 ms | 82432 KB | Output is correct |
14 | Correct | 32 ms | 82480 KB | Output is correct |
15 | Correct | 32 ms | 82476 KB | Output is correct |
16 | Correct | 31 ms | 82384 KB | Output is correct |
17 | Correct | 38 ms | 82432 KB | Output is correct |
18 | Correct | 34 ms | 82484 KB | Output is correct |
19 | Correct | 34 ms | 82484 KB | Output is correct |
20 | Correct | 37 ms | 82452 KB | Output is correct |
21 | Correct | 32 ms | 82416 KB | Output is correct |
22 | Correct | 32 ms | 82372 KB | Output is correct |
23 | Correct | 33 ms | 82388 KB | Output is correct |
24 | Correct | 34 ms | 82420 KB | Output is correct |
25 | Correct | 34 ms | 82384 KB | Output is correct |
26 | Correct | 33 ms | 82408 KB | Output is correct |
27 | Correct | 32 ms | 82388 KB | Output is correct |
28 | Correct | 32 ms | 82396 KB | Output is correct |
29 | Correct | 34 ms | 82384 KB | Output is correct |
30 | Correct | 31 ms | 82488 KB | Output is correct |
31 | Correct | 33 ms | 82384 KB | Output is correct |
32 | Correct | 30 ms | 82440 KB | Output is correct |
33 | Correct | 39 ms | 82380 KB | Output is correct |
34 | Correct | 35 ms | 82472 KB | Output is correct |
35 | Correct | 37 ms | 82592 KB | Output is correct |
36 | Correct | 34 ms | 82476 KB | Output is correct |
37 | Correct | 33 ms | 82476 KB | Output is correct |
38 | Correct | 32 ms | 82384 KB | Output is correct |
39 | Correct | 33 ms | 82504 KB | Output is correct |
40 | Correct | 34 ms | 82380 KB | Output is correct |
41 | Correct | 34 ms | 82448 KB | Output is correct |
42 | Correct | 34 ms | 82412 KB | Output is correct |
43 | Correct | 33 ms | 82428 KB | Output is correct |
44 | Correct | 40 ms | 82388 KB | Output is correct |
45 | Correct | 33 ms | 82424 KB | Output is correct |
46 | Correct | 33 ms | 82480 KB | Output is correct |
47 | Correct | 31 ms | 82468 KB | Output is correct |
48 | Correct | 38 ms | 82416 KB | Output is correct |
49 | Correct | 36 ms | 82380 KB | Output is correct |
50 | Correct | 38 ms | 82448 KB | Output is correct |
51 | Correct | 35 ms | 82452 KB | Output is correct |
52 | Correct | 38 ms | 82376 KB | Output is correct |
53 | Correct | 33 ms | 82388 KB | Output is correct |
54 | Correct | 33 ms | 82412 KB | Output is correct |
55 | Correct | 34 ms | 82416 KB | Output is correct |
56 | Correct | 34 ms | 82428 KB | Output is correct |
57 | Correct | 34 ms | 82380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 82376 KB | Output is correct |
2 | Correct | 32 ms | 82464 KB | Output is correct |
3 | Correct | 36 ms | 82428 KB | Output is correct |
4 | Correct | 38 ms | 82480 KB | Output is correct |
5 | Correct | 31 ms | 82436 KB | Output is correct |
6 | Correct | 32 ms | 82540 KB | Output is correct |
7 | Correct | 36 ms | 82368 KB | Output is correct |
8 | Correct | 32 ms | 82380 KB | Output is correct |
9 | Correct | 32 ms | 82468 KB | Output is correct |
10 | Correct | 32 ms | 82376 KB | Output is correct |
11 | Correct | 39 ms | 82380 KB | Output is correct |
12 | Correct | 33 ms | 82484 KB | Output is correct |
13 | Correct | 34 ms | 82432 KB | Output is correct |
14 | Correct | 32 ms | 82480 KB | Output is correct |
15 | Correct | 32 ms | 82476 KB | Output is correct |
16 | Correct | 31 ms | 82384 KB | Output is correct |
17 | Correct | 38 ms | 82432 KB | Output is correct |
18 | Correct | 34 ms | 82484 KB | Output is correct |
19 | Correct | 34 ms | 82484 KB | Output is correct |
20 | Correct | 37 ms | 82452 KB | Output is correct |
21 | Correct | 32 ms | 82416 KB | Output is correct |
22 | Correct | 32 ms | 82372 KB | Output is correct |
23 | Correct | 33 ms | 82388 KB | Output is correct |
24 | Correct | 34 ms | 82420 KB | Output is correct |
25 | Correct | 34 ms | 82384 KB | Output is correct |
26 | Correct | 33 ms | 82408 KB | Output is correct |
27 | Correct | 32 ms | 82388 KB | Output is correct |
28 | Correct | 32 ms | 82396 KB | Output is correct |
29 | Correct | 34 ms | 82384 KB | Output is correct |
30 | Correct | 31 ms | 82488 KB | Output is correct |
31 | Correct | 33 ms | 82384 KB | Output is correct |
32 | Correct | 30 ms | 82440 KB | Output is correct |
33 | Correct | 39 ms | 82380 KB | Output is correct |
34 | Correct | 35 ms | 82472 KB | Output is correct |
35 | Correct | 37 ms | 82592 KB | Output is correct |
36 | Correct | 34 ms | 82476 KB | Output is correct |
37 | Correct | 33 ms | 82476 KB | Output is correct |
38 | Correct | 32 ms | 82384 KB | Output is correct |
39 | Correct | 33 ms | 82504 KB | Output is correct |
40 | Correct | 34 ms | 82380 KB | Output is correct |
41 | Correct | 34 ms | 82448 KB | Output is correct |
42 | Correct | 34 ms | 82412 KB | Output is correct |
43 | Correct | 33 ms | 82428 KB | Output is correct |
44 | Correct | 40 ms | 82388 KB | Output is correct |
45 | Correct | 33 ms | 82424 KB | Output is correct |
46 | Correct | 33 ms | 82480 KB | Output is correct |
47 | Correct | 31 ms | 82468 KB | Output is correct |
48 | Correct | 38 ms | 82416 KB | Output is correct |
49 | Correct | 36 ms | 82380 KB | Output is correct |
50 | Correct | 38 ms | 82448 KB | Output is correct |
51 | Correct | 35 ms | 82452 KB | Output is correct |
52 | Correct | 38 ms | 82376 KB | Output is correct |
53 | Correct | 33 ms | 82388 KB | Output is correct |
54 | Correct | 33 ms | 82412 KB | Output is correct |
55 | Correct | 34 ms | 82416 KB | Output is correct |
56 | Correct | 34 ms | 82428 KB | Output is correct |
57 | Correct | 34 ms | 82380 KB | Output is correct |
58 | Correct | 38 ms | 82508 KB | Output is correct |
59 | Correct | 48 ms | 83020 KB | Output is correct |
60 | Correct | 51 ms | 83020 KB | Output is correct |
61 | Correct | 83 ms | 83144 KB | Output is correct |
62 | Correct | 163 ms | 83912 KB | Output is correct |
63 | Correct | 64 ms | 83900 KB | Output is correct |
64 | Correct | 118 ms | 83956 KB | Output is correct |
65 | Correct | 41 ms | 82412 KB | Output is correct |
66 | Correct | 32 ms | 82484 KB | Output is correct |
67 | Correct | 31 ms | 82460 KB | Output is correct |
68 | Correct | 32 ms | 82360 KB | Output is correct |
69 | Correct | 33 ms | 82488 KB | Output is correct |
70 | Correct | 33 ms | 82500 KB | Output is correct |
71 | Correct | 49 ms | 82748 KB | Output is correct |
72 | Correct | 38 ms | 82508 KB | Output is correct |
73 | Correct | 41 ms | 82632 KB | Output is correct |
74 | Correct | 60 ms | 83076 KB | Output is correct |
75 | Correct | 46 ms | 83028 KB | Output is correct |
76 | Correct | 78 ms | 83084 KB | Output is correct |
77 | Correct | 147 ms | 83896 KB | Output is correct |
78 | Correct | 74 ms | 83900 KB | Output is correct |
79 | Correct | 106 ms | 84012 KB | Output is correct |
80 | Correct | 60 ms | 83916 KB | Output is correct |
81 | Correct | 68 ms | 83916 KB | Output is correct |
82 | Correct | 152 ms | 83940 KB | Output is correct |
83 | Correct | 35 ms | 82464 KB | Output is correct |
84 | Correct | 33 ms | 82436 KB | Output is correct |
85 | Correct | 55 ms | 82608 KB | Output is correct |
86 | Correct | 35 ms | 82656 KB | Output is correct |
87 | Correct | 41 ms | 82680 KB | Output is correct |
88 | Correct | 48 ms | 83140 KB | Output is correct |
89 | Correct | 54 ms | 83396 KB | Output is correct |
90 | Correct | 100 ms | 83528 KB | Output is correct |
91 | Correct | 234 ms | 84688 KB | Output is correct |
92 | Correct | 67 ms | 84540 KB | Output is correct |
93 | Correct | 161 ms | 84736 KB | Output is correct |
94 | Correct | 35 ms | 82636 KB | Output is correct |
95 | Correct | 46 ms | 82644 KB | Output is correct |
96 | Correct | 33 ms | 82508 KB | Output is correct |
97 | Correct | 41 ms | 82484 KB | Output is correct |
98 | Correct | 33 ms | 82380 KB | Output is correct |
99 | Correct | 33 ms | 82380 KB | Output is correct |