Submission #484064

# Submission time Handle Problem Language Result Execution time Memory
484064 2021-11-02T03:37:24 Z kaxzert Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 3004 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() {
    #ifndef TAP 
   // setIO("triusis2019");
    //setIOusaco("triusis2019");
    #endif

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

    vt<int> f(n+2, 1e9);
    f[0] = 0;
    fto(i, 1, n+1) {
        fto(j, 0, i-1) {
            if (f[j] != 1e9 && h[j]+(i-j)*m >= h[i]) {
                f[i] = min(f[i], f[j]+(i-j-1));
            }
        }
    }

    cout << f[n+1] << '\n';

    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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 1 ms 256 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 1 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 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory 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 1 ms 256 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 1 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 0 ms 204 KB Output is correct
15 Correct 0 ms 204 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 28 ms 332 KB Output is correct
21 Correct 42 ms 364 KB Output is correct
22 Correct 9 ms 332 KB Output is correct
23 Correct 44 ms 332 KB Output is correct
24 Correct 43 ms 380 KB Output is correct
25 Correct 44 ms 332 KB Output is correct
26 Correct 42 ms 332 KB Output is correct
27 Correct 37 ms 332 KB Output is correct
28 Correct 42 ms 332 KB Output is correct
29 Correct 41 ms 300 KB Output is correct
30 Correct 44 ms 332 KB Output is correct
31 Correct 29 ms 372 KB Output is correct
32 Correct 43 ms 332 KB Output is correct
33 Correct 43 ms 372 KB Output is correct
# Verdict Execution time Memory 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 28 ms 332 KB Output is correct
5 Correct 42 ms 364 KB Output is correct
6 Correct 9 ms 332 KB Output is correct
7 Correct 44 ms 332 KB Output is correct
8 Correct 43 ms 380 KB Output is correct
9 Correct 44 ms 332 KB Output is correct
10 Correct 42 ms 332 KB Output is correct
11 Correct 37 ms 332 KB Output is correct
12 Correct 42 ms 332 KB Output is correct
13 Correct 41 ms 300 KB Output is correct
14 Correct 44 ms 332 KB Output is correct
15 Correct 29 ms 372 KB Output is correct
16 Correct 43 ms 332 KB Output is correct
17 Correct 43 ms 372 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 1 ms 256 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 1 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 0 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 9 ms 332 KB Output is correct
35 Correct 11 ms 332 KB Output is correct
36 Correct 11 ms 420 KB Output is correct
37 Correct 44 ms 332 KB Output is correct
38 Correct 37 ms 392 KB Output is correct
39 Correct 42 ms 332 KB Output is correct
40 Correct 30 ms 368 KB Output is correct
41 Correct 14 ms 400 KB Output is correct
42 Correct 43 ms 332 KB Output is correct
43 Correct 42 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 332 KB Output is correct
2 Correct 11 ms 332 KB Output is correct
3 Correct 11 ms 420 KB Output is correct
4 Correct 44 ms 332 KB Output is correct
5 Correct 37 ms 392 KB Output is correct
6 Correct 42 ms 332 KB Output is correct
7 Correct 30 ms 368 KB Output is correct
8 Correct 14 ms 400 KB Output is correct
9 Correct 43 ms 332 KB Output is correct
10 Correct 42 ms 380 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 28 ms 332 KB Output is correct
15 Correct 42 ms 364 KB Output is correct
16 Correct 9 ms 332 KB Output is correct
17 Correct 44 ms 332 KB Output is correct
18 Correct 43 ms 380 KB Output is correct
19 Correct 44 ms 332 KB Output is correct
20 Correct 42 ms 332 KB Output is correct
21 Correct 37 ms 332 KB Output is correct
22 Correct 42 ms 332 KB Output is correct
23 Correct 41 ms 300 KB Output is correct
24 Correct 44 ms 332 KB Output is correct
25 Correct 29 ms 372 KB Output is correct
26 Correct 43 ms 332 KB Output is correct
27 Correct 43 ms 372 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 256 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 1 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 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Execution timed out 1088 ms 3004 KB Time limit exceeded
45 Halted 0 ms 0 KB -