답안 #684836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684836 2023-01-22T15:18:58 Z vjudge1 K개의 묶음 (IZhO14_blocks) C++14
100 / 100
297 ms 82328 KB
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
const auto seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937_64 ran(seed);

#define ll long long
#define int long long
#define se second
#define fi first
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define REP(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FOD(i,r,l) for(int i=r; i>=l; i--)
#define ed <<'\n';

int n, k;
int a[200000];
int f[100004][102];

signed main(){
#define task "a"
    if(fopen(task".inp","r")) {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }

    cin >> n >> k;

    memset(f, 0x3f, sizeof f);
    f[0][1] = 0 ;
    FOR(i ,1, n) cin >> a[i], f[i][1] = max(f[i-1][1], a[i]);
    f[0][1] = 1e9 ;

    FOR(j ,2, k){
        stack <pair <int,int>> st;
        FOR(i ,1, n){
            int mn = f[i-1][j-1];

            while(st.size() && a[st.top().fi] <= a[i]){
                mn = min(mn, st.top().se);
                st.pop();
            }

            f[i][j] = min(mn + a[i], f[st.size() ? st.top().fi : 0][j]);
            st.push(make_pair(i, mn));
        }
    }

    cout << f[n][k];
}










Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 80132 KB Output is correct
2 Correct 37 ms 80120 KB Output is correct
3 Correct 34 ms 80108 KB Output is correct
4 Correct 31 ms 80084 KB Output is correct
5 Correct 30 ms 80108 KB Output is correct
6 Correct 30 ms 80092 KB Output is correct
7 Correct 31 ms 80044 KB Output is correct
8 Correct 31 ms 80032 KB Output is correct
9 Correct 34 ms 80052 KB Output is correct
10 Correct 31 ms 80084 KB Output is correct
11 Correct 30 ms 80084 KB Output is correct
12 Correct 31 ms 80104 KB Output is correct
13 Correct 32 ms 80076 KB Output is correct
14 Correct 31 ms 80112 KB Output is correct
15 Correct 30 ms 80076 KB Output is correct
16 Correct 34 ms 80084 KB Output is correct
17 Correct 31 ms 80084 KB Output is correct
18 Correct 31 ms 80072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 80136 KB Output is correct
2 Correct 36 ms 80084 KB Output is correct
3 Correct 32 ms 80044 KB Output is correct
4 Correct 34 ms 80084 KB Output is correct
5 Correct 33 ms 80032 KB Output is correct
6 Correct 32 ms 80084 KB Output is correct
7 Correct 38 ms 80052 KB Output is correct
8 Correct 30 ms 80052 KB Output is correct
9 Correct 30 ms 80068 KB Output is correct
10 Correct 30 ms 80084 KB Output is correct
11 Correct 32 ms 80172 KB Output is correct
12 Correct 28 ms 80152 KB Output is correct
13 Correct 30 ms 80036 KB Output is correct
14 Correct 35 ms 80132 KB Output is correct
15 Correct 30 ms 80120 KB Output is correct
16 Correct 30 ms 80084 KB Output is correct
17 Correct 30 ms 80096 KB Output is correct
18 Correct 29 ms 80076 KB Output is correct
19 Correct 30 ms 80128 KB Output is correct
20 Correct 30 ms 80028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 80132 KB Output is correct
2 Correct 37 ms 80120 KB Output is correct
3 Correct 34 ms 80108 KB Output is correct
4 Correct 31 ms 80084 KB Output is correct
5 Correct 30 ms 80108 KB Output is correct
6 Correct 30 ms 80092 KB Output is correct
7 Correct 31 ms 80044 KB Output is correct
8 Correct 31 ms 80032 KB Output is correct
9 Correct 34 ms 80052 KB Output is correct
10 Correct 31 ms 80084 KB Output is correct
11 Correct 30 ms 80084 KB Output is correct
12 Correct 31 ms 80104 KB Output is correct
13 Correct 32 ms 80076 KB Output is correct
14 Correct 31 ms 80112 KB Output is correct
15 Correct 30 ms 80076 KB Output is correct
16 Correct 34 ms 80084 KB Output is correct
17 Correct 31 ms 80084 KB Output is correct
18 Correct 31 ms 80072 KB Output is correct
19 Correct 32 ms 80136 KB Output is correct
20 Correct 36 ms 80084 KB Output is correct
21 Correct 32 ms 80044 KB Output is correct
22 Correct 34 ms 80084 KB Output is correct
23 Correct 33 ms 80032 KB Output is correct
24 Correct 32 ms 80084 KB Output is correct
25 Correct 38 ms 80052 KB Output is correct
26 Correct 30 ms 80052 KB Output is correct
27 Correct 30 ms 80068 KB Output is correct
28 Correct 30 ms 80084 KB Output is correct
29 Correct 32 ms 80172 KB Output is correct
30 Correct 28 ms 80152 KB Output is correct
31 Correct 30 ms 80036 KB Output is correct
32 Correct 35 ms 80132 KB Output is correct
33 Correct 30 ms 80120 KB Output is correct
34 Correct 30 ms 80084 KB Output is correct
35 Correct 30 ms 80096 KB Output is correct
36 Correct 29 ms 80076 KB Output is correct
37 Correct 30 ms 80128 KB Output is correct
38 Correct 30 ms 80028 KB Output is correct
39 Correct 30 ms 80100 KB Output is correct
40 Correct 30 ms 80120 KB Output is correct
41 Correct 33 ms 80036 KB Output is correct
42 Correct 32 ms 80056 KB Output is correct
43 Correct 31 ms 80088 KB Output is correct
44 Correct 29 ms 80100 KB Output is correct
45 Correct 37 ms 80072 KB Output is correct
46 Correct 34 ms 80096 KB Output is correct
47 Correct 30 ms 80072 KB Output is correct
48 Correct 33 ms 80056 KB Output is correct
49 Correct 30 ms 80088 KB Output is correct
50 Correct 30 ms 80092 KB Output is correct
51 Correct 30 ms 80084 KB Output is correct
52 Correct 30 ms 80164 KB Output is correct
53 Correct 32 ms 80132 KB Output is correct
54 Correct 31 ms 80088 KB Output is correct
55 Correct 31 ms 80028 KB Output is correct
56 Correct 37 ms 80060 KB Output is correct
57 Correct 33 ms 80056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 80132 KB Output is correct
2 Correct 37 ms 80120 KB Output is correct
3 Correct 34 ms 80108 KB Output is correct
4 Correct 31 ms 80084 KB Output is correct
5 Correct 30 ms 80108 KB Output is correct
6 Correct 30 ms 80092 KB Output is correct
7 Correct 31 ms 80044 KB Output is correct
8 Correct 31 ms 80032 KB Output is correct
9 Correct 34 ms 80052 KB Output is correct
10 Correct 31 ms 80084 KB Output is correct
11 Correct 30 ms 80084 KB Output is correct
12 Correct 31 ms 80104 KB Output is correct
13 Correct 32 ms 80076 KB Output is correct
14 Correct 31 ms 80112 KB Output is correct
15 Correct 30 ms 80076 KB Output is correct
16 Correct 34 ms 80084 KB Output is correct
17 Correct 31 ms 80084 KB Output is correct
18 Correct 31 ms 80072 KB Output is correct
19 Correct 32 ms 80136 KB Output is correct
20 Correct 36 ms 80084 KB Output is correct
21 Correct 32 ms 80044 KB Output is correct
22 Correct 34 ms 80084 KB Output is correct
23 Correct 33 ms 80032 KB Output is correct
24 Correct 32 ms 80084 KB Output is correct
25 Correct 38 ms 80052 KB Output is correct
26 Correct 30 ms 80052 KB Output is correct
27 Correct 30 ms 80068 KB Output is correct
28 Correct 30 ms 80084 KB Output is correct
29 Correct 32 ms 80172 KB Output is correct
30 Correct 28 ms 80152 KB Output is correct
31 Correct 30 ms 80036 KB Output is correct
32 Correct 35 ms 80132 KB Output is correct
33 Correct 30 ms 80120 KB Output is correct
34 Correct 30 ms 80084 KB Output is correct
35 Correct 30 ms 80096 KB Output is correct
36 Correct 29 ms 80076 KB Output is correct
37 Correct 30 ms 80128 KB Output is correct
38 Correct 30 ms 80028 KB Output is correct
39 Correct 30 ms 80100 KB Output is correct
40 Correct 30 ms 80120 KB Output is correct
41 Correct 33 ms 80036 KB Output is correct
42 Correct 32 ms 80056 KB Output is correct
43 Correct 31 ms 80088 KB Output is correct
44 Correct 29 ms 80100 KB Output is correct
45 Correct 37 ms 80072 KB Output is correct
46 Correct 34 ms 80096 KB Output is correct
47 Correct 30 ms 80072 KB Output is correct
48 Correct 33 ms 80056 KB Output is correct
49 Correct 30 ms 80088 KB Output is correct
50 Correct 30 ms 80092 KB Output is correct
51 Correct 30 ms 80084 KB Output is correct
52 Correct 30 ms 80164 KB Output is correct
53 Correct 32 ms 80132 KB Output is correct
54 Correct 31 ms 80088 KB Output is correct
55 Correct 31 ms 80028 KB Output is correct
56 Correct 37 ms 80060 KB Output is correct
57 Correct 33 ms 80056 KB Output is correct
58 Correct 35 ms 80212 KB Output is correct
59 Correct 41 ms 80744 KB Output is correct
60 Correct 46 ms 80720 KB Output is correct
61 Correct 92 ms 80788 KB Output is correct
62 Correct 297 ms 81484 KB Output is correct
63 Correct 70 ms 81484 KB Output is correct
64 Correct 161 ms 81604 KB Output is correct
65 Correct 31 ms 80028 KB Output is correct
66 Correct 31 ms 80060 KB Output is correct
67 Correct 30 ms 80056 KB Output is correct
68 Correct 34 ms 80148 KB Output is correct
69 Correct 31 ms 80152 KB Output is correct
70 Correct 30 ms 80044 KB Output is correct
71 Correct 56 ms 80160 KB Output is correct
72 Correct 34 ms 80204 KB Output is correct
73 Correct 38 ms 80176 KB Output is correct
74 Correct 43 ms 80776 KB Output is correct
75 Correct 48 ms 80780 KB Output is correct
76 Correct 97 ms 80784 KB Output is correct
77 Correct 238 ms 81680 KB Output is correct
78 Correct 66 ms 81544 KB Output is correct
79 Correct 145 ms 81576 KB Output is correct
80 Correct 60 ms 81488 KB Output is correct
81 Correct 78 ms 81484 KB Output is correct
82 Correct 245 ms 81600 KB Output is correct
83 Correct 32 ms 80124 KB Output is correct
84 Correct 30 ms 80084 KB Output is correct
85 Correct 53 ms 80292 KB Output is correct
86 Correct 38 ms 80312 KB Output is correct
87 Correct 41 ms 80320 KB Output is correct
88 Correct 47 ms 80732 KB Output is correct
89 Correct 46 ms 80992 KB Output is correct
90 Correct 100 ms 81112 KB Output is correct
91 Correct 296 ms 82328 KB Output is correct
92 Correct 67 ms 82128 KB Output is correct
93 Correct 154 ms 82184 KB Output is correct
94 Correct 33 ms 80260 KB Output is correct
95 Correct 47 ms 80204 KB Output is correct
96 Correct 30 ms 80076 KB Output is correct
97 Correct 29 ms 80036 KB Output is correct
98 Correct 29 ms 80076 KB Output is correct
99 Correct 30 ms 80096 KB Output is correct