답안 #483740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483740 2021-11-01T02:06:57 Z kaxzert Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
149 ms 262148 KB
/**
      00  00      11      00  00  111111  00000  111111  000000
      00 00      1111      0000      11   00     11  11  000000
      0000      11  11      00      11    00000  111111    00
      00 00    11111111    0000    11     00     11 11     00
      00  00  11      11  00  00  111111  00000  11  11    00
**/

#include<bits/stdc++.h>

using namespace std;

#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl;
#define ll long long
#define db double
#define ldb long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define vt vector
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(i, a) for(auto &i : a)
#define sz(a) (int)a.size()
#define pi(a, b) pair<a, b>
#define fast ios::sync_with_stdio(false); cin.tie(0)

void setIO(string s) {
    if (sz(s) != 0) {
        freopen((s+".inp").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

void setIOusaco(string s) {
    if (sz(s) != 0) {
        freopen((s+".in").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

template<typename T, typename V>
bool ckmin(T &a, V b) {return (b < a)? a = b, true : false;}
template<typename T, typename V>
bool ckmax(T &a, V b) {return (b > a)? a = b, true : false;}

int main() {

    fast;
    int n, m;
    cin >> n >> m;
    vt<ll> h(n+1);
    fto(i, 1, n) {
    	cin >> h[i];
    }

    vt<vt<ll> > f(n+1, vt<ll>(n+1, -1));

    f[0][0] = 0;
    fto(i, 1, n) {
    	fto(j, 0, i) {
    		if (f[i-1][j] != -1 && f[i-1][j]+m >= h[i]) f[i][j] = max(f[i][j], h[i]);
    		if (j && f[i-1][j-1] != -1) f[i][j] = max(f[i][j], f[i-1][j-1]+m); 
    	}
    }

    fto(i, 0, n) {
    	if (f[n][i] != -1) {
    		cout << i << '\n';
    		return 0;
    	}
    }

    return 0;
}

Compilation message

triusis.cpp: In function 'void setIO(std::string)':
triusis.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen((s+".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp: In function 'void setIOusaco(std::string)':
triusis.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen((s+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 99 ms 128944 KB Output is correct
21 Correct 149 ms 196240 KB Output is correct
22 Correct 117 ms 196304 KB Output is correct
23 Correct 140 ms 196284 KB Output is correct
24 Correct 147 ms 196252 KB Output is correct
25 Correct 139 ms 196292 KB Output is correct
26 Correct 147 ms 196324 KB Output is correct
27 Correct 145 ms 196284 KB Output is correct
28 Correct 148 ms 196316 KB Output is correct
29 Correct 149 ms 196292 KB Output is correct
30 Correct 138 ms 196344 KB Output is correct
31 Correct 120 ms 196292 KB Output is correct
32 Correct 135 ms 196320 KB Output is correct
33 Correct 129 ms 196284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 99 ms 128944 KB Output is correct
5 Correct 149 ms 196240 KB Output is correct
6 Correct 117 ms 196304 KB Output is correct
7 Correct 140 ms 196284 KB Output is correct
8 Correct 147 ms 196252 KB Output is correct
9 Correct 139 ms 196292 KB Output is correct
10 Correct 147 ms 196324 KB Output is correct
11 Correct 145 ms 196284 KB Output is correct
12 Correct 148 ms 196316 KB Output is correct
13 Correct 149 ms 196292 KB Output is correct
14 Correct 138 ms 196344 KB Output is correct
15 Correct 120 ms 196292 KB Output is correct
16 Correct 135 ms 196320 KB Output is correct
17 Correct 129 ms 196284 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 0 ms 304 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 89 ms 196312 KB Output is correct
35 Correct 90 ms 196268 KB Output is correct
36 Correct 89 ms 196292 KB Output is correct
37 Correct 147 ms 196320 KB Output is correct
38 Correct 113 ms 196336 KB Output is correct
39 Correct 148 ms 196260 KB Output is correct
40 Correct 121 ms 196316 KB Output is correct
41 Correct 89 ms 196236 KB Output is correct
42 Correct 132 ms 196276 KB Output is correct
43 Correct 138 ms 196420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 196312 KB Output is correct
2 Correct 90 ms 196268 KB Output is correct
3 Correct 89 ms 196292 KB Output is correct
4 Correct 147 ms 196320 KB Output is correct
5 Correct 113 ms 196336 KB Output is correct
6 Correct 148 ms 196260 KB Output is correct
7 Correct 121 ms 196316 KB Output is correct
8 Correct 89 ms 196236 KB Output is correct
9 Correct 132 ms 196276 KB Output is correct
10 Correct 138 ms 196420 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 99 ms 128944 KB Output is correct
15 Correct 149 ms 196240 KB Output is correct
16 Correct 117 ms 196304 KB Output is correct
17 Correct 140 ms 196284 KB Output is correct
18 Correct 147 ms 196252 KB Output is correct
19 Correct 139 ms 196292 KB Output is correct
20 Correct 147 ms 196324 KB Output is correct
21 Correct 145 ms 196284 KB Output is correct
22 Correct 148 ms 196316 KB Output is correct
23 Correct 149 ms 196292 KB Output is correct
24 Correct 138 ms 196344 KB Output is correct
25 Correct 120 ms 196292 KB Output is correct
26 Correct 135 ms 196320 KB Output is correct
27 Correct 129 ms 196284 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 304 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Runtime error 102 ms 262148 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -