Submission #684830

# Submission time Handle Problem Language Result Execution time Memory
684830 2023-01-22T14:43:36 Z vjudge1 K blocks (IZhO14_blocks) C++14
53 / 100
1000 ms 80204 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 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--)


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]);

    FOR(i ,1, n){
        FOR(j ,2, k){
            int mx = 0; 
            FOD(x ,i, 2){
                mx = max(mx , a[x]); 
                f[i][j] = min(f[i][j], f[x - 1][j - 1] + mx);
            }
        }
    }

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










Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 39 ms 80116 KB Output is correct
2 Correct 30 ms 80140 KB Output is correct
3 Correct 30 ms 80052 KB Output is correct
4 Correct 30 ms 80052 KB Output is correct
5 Correct 31 ms 80076 KB Output is correct
6 Correct 30 ms 80064 KB Output is correct
7 Correct 30 ms 80056 KB Output is correct
8 Correct 30 ms 80128 KB Output is correct
9 Correct 37 ms 80080 KB Output is correct
10 Correct 36 ms 80076 KB Output is correct
11 Correct 30 ms 80128 KB Output is correct
12 Correct 32 ms 80052 KB Output is correct
13 Correct 33 ms 80076 KB Output is correct
14 Correct 31 ms 80044 KB Output is correct
15 Correct 33 ms 80112 KB Output is correct
16 Correct 31 ms 80092 KB Output is correct
17 Correct 35 ms 80068 KB Output is correct
18 Correct 36 ms 80068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 80056 KB Output is correct
2 Correct 30 ms 80068 KB Output is correct
3 Correct 37 ms 80028 KB Output is correct
4 Correct 31 ms 80120 KB Output is correct
5 Correct 35 ms 80164 KB Output is correct
6 Correct 31 ms 80140 KB Output is correct
7 Correct 31 ms 80128 KB Output is correct
8 Correct 31 ms 80040 KB Output is correct
9 Correct 30 ms 80148 KB Output is correct
10 Correct 30 ms 80084 KB Output is correct
11 Correct 30 ms 80056 KB Output is correct
12 Correct 31 ms 80080 KB Output is correct
13 Correct 33 ms 80100 KB Output is correct
14 Correct 30 ms 80048 KB Output is correct
15 Correct 29 ms 80076 KB Output is correct
16 Correct 31 ms 80152 KB Output is correct
17 Correct 32 ms 80076 KB Output is correct
18 Correct 31 ms 80120 KB Output is correct
19 Correct 31 ms 80136 KB Output is correct
20 Correct 38 ms 80072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 80116 KB Output is correct
2 Correct 30 ms 80140 KB Output is correct
3 Correct 30 ms 80052 KB Output is correct
4 Correct 30 ms 80052 KB Output is correct
5 Correct 31 ms 80076 KB Output is correct
6 Correct 30 ms 80064 KB Output is correct
7 Correct 30 ms 80056 KB Output is correct
8 Correct 30 ms 80128 KB Output is correct
9 Correct 37 ms 80080 KB Output is correct
10 Correct 36 ms 80076 KB Output is correct
11 Correct 30 ms 80128 KB Output is correct
12 Correct 32 ms 80052 KB Output is correct
13 Correct 33 ms 80076 KB Output is correct
14 Correct 31 ms 80044 KB Output is correct
15 Correct 33 ms 80112 KB Output is correct
16 Correct 31 ms 80092 KB Output is correct
17 Correct 35 ms 80068 KB Output is correct
18 Correct 36 ms 80068 KB Output is correct
19 Correct 31 ms 80056 KB Output is correct
20 Correct 30 ms 80068 KB Output is correct
21 Correct 37 ms 80028 KB Output is correct
22 Correct 31 ms 80120 KB Output is correct
23 Correct 35 ms 80164 KB Output is correct
24 Correct 31 ms 80140 KB Output is correct
25 Correct 31 ms 80128 KB Output is correct
26 Correct 31 ms 80040 KB Output is correct
27 Correct 30 ms 80148 KB Output is correct
28 Correct 30 ms 80084 KB Output is correct
29 Correct 30 ms 80056 KB Output is correct
30 Correct 31 ms 80080 KB Output is correct
31 Correct 33 ms 80100 KB Output is correct
32 Correct 30 ms 80048 KB Output is correct
33 Correct 29 ms 80076 KB Output is correct
34 Correct 31 ms 80152 KB Output is correct
35 Correct 32 ms 80076 KB Output is correct
36 Correct 31 ms 80120 KB Output is correct
37 Correct 31 ms 80136 KB Output is correct
38 Correct 38 ms 80072 KB Output is correct
39 Correct 32 ms 80060 KB Output is correct
40 Correct 30 ms 80056 KB Output is correct
41 Correct 30 ms 80156 KB Output is correct
42 Correct 30 ms 80076 KB Output is correct
43 Correct 30 ms 80128 KB Output is correct
44 Correct 30 ms 80076 KB Output is correct
45 Correct 30 ms 80088 KB Output is correct
46 Correct 30 ms 80128 KB Output is correct
47 Correct 29 ms 80096 KB Output is correct
48 Correct 30 ms 80076 KB Output is correct
49 Correct 29 ms 80064 KB Output is correct
50 Correct 30 ms 80072 KB Output is correct
51 Correct 31 ms 80136 KB Output is correct
52 Correct 30 ms 80128 KB Output is correct
53 Correct 31 ms 80100 KB Output is correct
54 Correct 31 ms 80076 KB Output is correct
55 Correct 30 ms 80052 KB Output is correct
56 Correct 32 ms 80084 KB Output is correct
57 Correct 33 ms 80148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 80116 KB Output is correct
2 Correct 30 ms 80140 KB Output is correct
3 Correct 30 ms 80052 KB Output is correct
4 Correct 30 ms 80052 KB Output is correct
5 Correct 31 ms 80076 KB Output is correct
6 Correct 30 ms 80064 KB Output is correct
7 Correct 30 ms 80056 KB Output is correct
8 Correct 30 ms 80128 KB Output is correct
9 Correct 37 ms 80080 KB Output is correct
10 Correct 36 ms 80076 KB Output is correct
11 Correct 30 ms 80128 KB Output is correct
12 Correct 32 ms 80052 KB Output is correct
13 Correct 33 ms 80076 KB Output is correct
14 Correct 31 ms 80044 KB Output is correct
15 Correct 33 ms 80112 KB Output is correct
16 Correct 31 ms 80092 KB Output is correct
17 Correct 35 ms 80068 KB Output is correct
18 Correct 36 ms 80068 KB Output is correct
19 Correct 31 ms 80056 KB Output is correct
20 Correct 30 ms 80068 KB Output is correct
21 Correct 37 ms 80028 KB Output is correct
22 Correct 31 ms 80120 KB Output is correct
23 Correct 35 ms 80164 KB Output is correct
24 Correct 31 ms 80140 KB Output is correct
25 Correct 31 ms 80128 KB Output is correct
26 Correct 31 ms 80040 KB Output is correct
27 Correct 30 ms 80148 KB Output is correct
28 Correct 30 ms 80084 KB Output is correct
29 Correct 30 ms 80056 KB Output is correct
30 Correct 31 ms 80080 KB Output is correct
31 Correct 33 ms 80100 KB Output is correct
32 Correct 30 ms 80048 KB Output is correct
33 Correct 29 ms 80076 KB Output is correct
34 Correct 31 ms 80152 KB Output is correct
35 Correct 32 ms 80076 KB Output is correct
36 Correct 31 ms 80120 KB Output is correct
37 Correct 31 ms 80136 KB Output is correct
38 Correct 38 ms 80072 KB Output is correct
39 Correct 32 ms 80060 KB Output is correct
40 Correct 30 ms 80056 KB Output is correct
41 Correct 30 ms 80156 KB Output is correct
42 Correct 30 ms 80076 KB Output is correct
43 Correct 30 ms 80128 KB Output is correct
44 Correct 30 ms 80076 KB Output is correct
45 Correct 30 ms 80088 KB Output is correct
46 Correct 30 ms 80128 KB Output is correct
47 Correct 29 ms 80096 KB Output is correct
48 Correct 30 ms 80076 KB Output is correct
49 Correct 29 ms 80064 KB Output is correct
50 Correct 30 ms 80072 KB Output is correct
51 Correct 31 ms 80136 KB Output is correct
52 Correct 30 ms 80128 KB Output is correct
53 Correct 31 ms 80100 KB Output is correct
54 Correct 31 ms 80076 KB Output is correct
55 Correct 30 ms 80052 KB Output is correct
56 Correct 32 ms 80084 KB Output is correct
57 Correct 33 ms 80148 KB Output is correct
58 Execution timed out 1083 ms 80204 KB Time limit exceeded
59 Halted 0 ms 0 KB -