Submission #789537

# Submission time Handle Problem Language Result Execution time Memory
789537 2023-07-21T13:19:18 Z nasam K blocks (IZhO14_blocks) C++17
53 / 100
1000 ms 84132 KB
#include <bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FOD(i,b,a) for (int i = (b), _a = (a); i >= _a; i--)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(i) (1LL << (i))
#define CNTBIT(x) __builtin_popcount(x)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define left ___left
#define right ___right
#define pii pair<int, int>
#define DEBUG(n, a) FOR (i, 1, n) cout << a[i] << ' '; cout << endl;1234567890
#define lob lower_bound // >=
#define upb upper_bound // >
#define endl "\n"

using namespace std;

template<class X, class Y> bool maximize(X &x, Y y){ if (x < y){ x = y; return true; } return false; }
template<class X, class Y> bool minimize(X &x, Y y){ if (x > y){ x = y; return true; } return false; }

#define  gogobruhbruh  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define  file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }

int MOD = 1e9 + 7;

int add(int &a, int b){ if ((a += b) >= MOD) a -= MOD; return a; }
int sub(int a, int b){ if ((a -= b) < 0) a += MOD; return a; }
int muti(int a, int b){ return (1LL * a * b) % MOD; }
int Pow(int x, int y){ int res = 1; for (; y; y >>= 1){ if (y & 1) res = muti(res, x); x = muti(x, x); } return res; }

const int MAX = 1e5 + 7;
const ll INF = 1e14;

int num, lim;
int val[MAX];
ll dp[MAX][107];

void solve(){
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    FOR (i, 1, num){
        int Max = val[i];
        FOD (j, i, 1){
            maximize(Max, val[j]);
            FOR (k, 1, lim)
                minimize(dp[i][k], dp[j - 1][k - 1] + Max);
        }
    }
    cout << dp[num][lim];
}

void read(){
    cin >> num >> lim;
    FOR (i, 1, num)
        cin >> val[i];
}

int main(){
    gogobruhbruh;
    file("main");
    int test = 1;
//    cin >> test;
    while (test--)
        read(),
        solve();
}

Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:28:61: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 | #define  file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:66:5: note: in expansion of macro 'file'
   66 |     file("main");
      |     ^~~~
blocks.cpp:28:95: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 | #define  file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                                                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:66:5: note: in expansion of macro 'file'
   66 |     file("main");
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 84060 KB Output is correct
2 Correct 32 ms 83976 KB Output is correct
3 Correct 27 ms 84020 KB Output is correct
4 Correct 28 ms 84004 KB Output is correct
5 Correct 27 ms 84024 KB Output is correct
6 Correct 26 ms 84056 KB Output is correct
7 Correct 30 ms 84052 KB Output is correct
8 Correct 25 ms 84004 KB Output is correct
9 Correct 25 ms 84044 KB Output is correct
10 Correct 24 ms 84008 KB Output is correct
11 Correct 27 ms 83960 KB Output is correct
12 Correct 26 ms 84084 KB Output is correct
13 Correct 26 ms 84040 KB Output is correct
14 Correct 30 ms 83952 KB Output is correct
15 Correct 27 ms 84052 KB Output is correct
16 Correct 25 ms 84052 KB Output is correct
17 Correct 28 ms 84060 KB Output is correct
18 Correct 26 ms 84064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 84008 KB Output is correct
2 Correct 33 ms 83952 KB Output is correct
3 Correct 24 ms 84028 KB Output is correct
4 Correct 26 ms 83988 KB Output is correct
5 Correct 25 ms 84052 KB Output is correct
6 Correct 26 ms 84028 KB Output is correct
7 Correct 31 ms 83984 KB Output is correct
8 Correct 32 ms 83960 KB Output is correct
9 Correct 26 ms 84004 KB Output is correct
10 Correct 30 ms 84052 KB Output is correct
11 Correct 25 ms 84004 KB Output is correct
12 Correct 31 ms 84056 KB Output is correct
13 Correct 27 ms 83996 KB Output is correct
14 Correct 26 ms 83972 KB Output is correct
15 Correct 32 ms 84016 KB Output is correct
16 Correct 27 ms 84048 KB Output is correct
17 Correct 25 ms 84000 KB Output is correct
18 Correct 25 ms 83984 KB Output is correct
19 Correct 26 ms 84068 KB Output is correct
20 Correct 25 ms 83988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 84060 KB Output is correct
2 Correct 32 ms 83976 KB Output is correct
3 Correct 27 ms 84020 KB Output is correct
4 Correct 28 ms 84004 KB Output is correct
5 Correct 27 ms 84024 KB Output is correct
6 Correct 26 ms 84056 KB Output is correct
7 Correct 30 ms 84052 KB Output is correct
8 Correct 25 ms 84004 KB Output is correct
9 Correct 25 ms 84044 KB Output is correct
10 Correct 24 ms 84008 KB Output is correct
11 Correct 27 ms 83960 KB Output is correct
12 Correct 26 ms 84084 KB Output is correct
13 Correct 26 ms 84040 KB Output is correct
14 Correct 30 ms 83952 KB Output is correct
15 Correct 27 ms 84052 KB Output is correct
16 Correct 25 ms 84052 KB Output is correct
17 Correct 28 ms 84060 KB Output is correct
18 Correct 26 ms 84064 KB Output is correct
19 Correct 27 ms 84008 KB Output is correct
20 Correct 33 ms 83952 KB Output is correct
21 Correct 24 ms 84028 KB Output is correct
22 Correct 26 ms 83988 KB Output is correct
23 Correct 25 ms 84052 KB Output is correct
24 Correct 26 ms 84028 KB Output is correct
25 Correct 31 ms 83984 KB Output is correct
26 Correct 32 ms 83960 KB Output is correct
27 Correct 26 ms 84004 KB Output is correct
28 Correct 30 ms 84052 KB Output is correct
29 Correct 25 ms 84004 KB Output is correct
30 Correct 31 ms 84056 KB Output is correct
31 Correct 27 ms 83996 KB Output is correct
32 Correct 26 ms 83972 KB Output is correct
33 Correct 32 ms 84016 KB Output is correct
34 Correct 27 ms 84048 KB Output is correct
35 Correct 25 ms 84000 KB Output is correct
36 Correct 25 ms 83984 KB Output is correct
37 Correct 26 ms 84068 KB Output is correct
38 Correct 25 ms 83988 KB Output is correct
39 Correct 26 ms 84132 KB Output is correct
40 Correct 24 ms 84048 KB Output is correct
41 Correct 30 ms 83968 KB Output is correct
42 Correct 31 ms 84008 KB Output is correct
43 Correct 25 ms 84060 KB Output is correct
44 Correct 25 ms 84016 KB Output is correct
45 Correct 26 ms 84004 KB Output is correct
46 Correct 25 ms 83968 KB Output is correct
47 Correct 26 ms 84000 KB Output is correct
48 Correct 25 ms 83952 KB Output is correct
49 Correct 31 ms 84052 KB Output is correct
50 Correct 25 ms 84052 KB Output is correct
51 Correct 25 ms 83980 KB Output is correct
52 Correct 28 ms 84044 KB Output is correct
53 Correct 28 ms 84044 KB Output is correct
54 Correct 25 ms 84016 KB Output is correct
55 Correct 32 ms 84068 KB Output is correct
56 Correct 32 ms 83984 KB Output is correct
57 Correct 26 ms 84052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 84060 KB Output is correct
2 Correct 32 ms 83976 KB Output is correct
3 Correct 27 ms 84020 KB Output is correct
4 Correct 28 ms 84004 KB Output is correct
5 Correct 27 ms 84024 KB Output is correct
6 Correct 26 ms 84056 KB Output is correct
7 Correct 30 ms 84052 KB Output is correct
8 Correct 25 ms 84004 KB Output is correct
9 Correct 25 ms 84044 KB Output is correct
10 Correct 24 ms 84008 KB Output is correct
11 Correct 27 ms 83960 KB Output is correct
12 Correct 26 ms 84084 KB Output is correct
13 Correct 26 ms 84040 KB Output is correct
14 Correct 30 ms 83952 KB Output is correct
15 Correct 27 ms 84052 KB Output is correct
16 Correct 25 ms 84052 KB Output is correct
17 Correct 28 ms 84060 KB Output is correct
18 Correct 26 ms 84064 KB Output is correct
19 Correct 27 ms 84008 KB Output is correct
20 Correct 33 ms 83952 KB Output is correct
21 Correct 24 ms 84028 KB Output is correct
22 Correct 26 ms 83988 KB Output is correct
23 Correct 25 ms 84052 KB Output is correct
24 Correct 26 ms 84028 KB Output is correct
25 Correct 31 ms 83984 KB Output is correct
26 Correct 32 ms 83960 KB Output is correct
27 Correct 26 ms 84004 KB Output is correct
28 Correct 30 ms 84052 KB Output is correct
29 Correct 25 ms 84004 KB Output is correct
30 Correct 31 ms 84056 KB Output is correct
31 Correct 27 ms 83996 KB Output is correct
32 Correct 26 ms 83972 KB Output is correct
33 Correct 32 ms 84016 KB Output is correct
34 Correct 27 ms 84048 KB Output is correct
35 Correct 25 ms 84000 KB Output is correct
36 Correct 25 ms 83984 KB Output is correct
37 Correct 26 ms 84068 KB Output is correct
38 Correct 25 ms 83988 KB Output is correct
39 Correct 26 ms 84132 KB Output is correct
40 Correct 24 ms 84048 KB Output is correct
41 Correct 30 ms 83968 KB Output is correct
42 Correct 31 ms 84008 KB Output is correct
43 Correct 25 ms 84060 KB Output is correct
44 Correct 25 ms 84016 KB Output is correct
45 Correct 26 ms 84004 KB Output is correct
46 Correct 25 ms 83968 KB Output is correct
47 Correct 26 ms 84000 KB Output is correct
48 Correct 25 ms 83952 KB Output is correct
49 Correct 31 ms 84052 KB Output is correct
50 Correct 25 ms 84052 KB Output is correct
51 Correct 25 ms 83980 KB Output is correct
52 Correct 28 ms 84044 KB Output is correct
53 Correct 28 ms 84044 KB Output is correct
54 Correct 25 ms 84016 KB Output is correct
55 Correct 32 ms 84068 KB Output is correct
56 Correct 32 ms 83984 KB Output is correct
57 Correct 26 ms 84052 KB Output is correct
58 Execution timed out 1088 ms 84072 KB Time limit exceeded
59 Halted 0 ms 0 KB -