답안 #486127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486127 2021-11-10T15:09:34 Z Duy_e Rabbit Carrot (LMIO19_triusis) C++14
63 / 100
1000 ms 4888 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<long long, long long>
#define st first
#define nd second
#define file "test"
using namespace std;
const long long oo = 1e18;
const long long N = 2e5 + 5;

ll n, m, h[N], dp[N], best[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
    // #endif
    
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
        cin >> h[i];

    for (int i = 0; i <= n + 1; i ++)
        dp[i] = oo, best[i] = i - 1;

    dp[0] = 0;
    for (int i = 1; i <= n + 1; i ++){
        for (int j = i - 1; j >= 0; j --)
            if (h[j] + (i - j)*m >= h[i])
                dp[i] = min(dp[i], dp[j] + i - j - 1);
        // cout << dp[i] << ' ';
    }


    cout << dp[n + 1];
    

    return 0;
}    
/**  /\_/\
    (= ._.)
    / >0  \>1 
  ________________________
 / Brainstorming section /
/=======================/
---
===
with two fixed point i, j you are allowed to change every pole between i, j
-> could it be changed so that you can go from i->j
possible case: 
+ a[j] <= a[i]
+ h[i] + (j - i)*m >= h[j]
        // upd(h[i]dp[i] - i - 1)
        // get(h[j] - j*m)

===
**/
// Before submit: spot the visible bug by reading the code. 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 28 ms 332 KB Output is correct
21 Correct 42 ms 436 KB Output is correct
22 Correct 45 ms 448 KB Output is correct
23 Correct 42 ms 332 KB Output is correct
24 Correct 43 ms 332 KB Output is correct
25 Correct 45 ms 332 KB Output is correct
26 Correct 43 ms 332 KB Output is correct
27 Correct 49 ms 332 KB Output is correct
28 Correct 44 ms 428 KB Output is correct
29 Correct 46 ms 332 KB Output is correct
30 Correct 43 ms 428 KB Output is correct
31 Correct 32 ms 332 KB Output is correct
32 Correct 42 ms 332 KB Output is correct
33 Correct 44 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 28 ms 332 KB Output is correct
5 Correct 42 ms 436 KB Output is correct
6 Correct 45 ms 448 KB Output is correct
7 Correct 42 ms 332 KB Output is correct
8 Correct 43 ms 332 KB Output is correct
9 Correct 45 ms 332 KB Output is correct
10 Correct 43 ms 332 KB Output is correct
11 Correct 49 ms 332 KB Output is correct
12 Correct 44 ms 428 KB Output is correct
13 Correct 46 ms 332 KB Output is correct
14 Correct 43 ms 428 KB Output is correct
15 Correct 32 ms 332 KB Output is correct
16 Correct 42 ms 332 KB Output is correct
17 Correct 44 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 45 ms 432 KB Output is correct
35 Correct 45 ms 332 KB Output is correct
36 Correct 48 ms 332 KB Output is correct
37 Correct 46 ms 332 KB Output is correct
38 Correct 44 ms 332 KB Output is correct
39 Correct 46 ms 332 KB Output is correct
40 Correct 31 ms 332 KB Output is correct
41 Correct 43 ms 428 KB Output is correct
42 Correct 46 ms 332 KB Output is correct
43 Correct 45 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 432 KB Output is correct
2 Correct 45 ms 332 KB Output is correct
3 Correct 48 ms 332 KB Output is correct
4 Correct 46 ms 332 KB Output is correct
5 Correct 44 ms 332 KB Output is correct
6 Correct 46 ms 332 KB Output is correct
7 Correct 31 ms 332 KB Output is correct
8 Correct 43 ms 428 KB Output is correct
9 Correct 46 ms 332 KB Output is correct
10 Correct 45 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 28 ms 332 KB Output is correct
15 Correct 42 ms 436 KB Output is correct
16 Correct 45 ms 448 KB Output is correct
17 Correct 42 ms 332 KB Output is correct
18 Correct 43 ms 332 KB Output is correct
19 Correct 45 ms 332 KB Output is correct
20 Correct 43 ms 332 KB Output is correct
21 Correct 49 ms 332 KB Output is correct
22 Correct 44 ms 428 KB Output is correct
23 Correct 46 ms 332 KB Output is correct
24 Correct 43 ms 428 KB Output is correct
25 Correct 32 ms 332 KB Output is correct
26 Correct 42 ms 332 KB Output is correct
27 Correct 44 ms 332 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 0 ms 332 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 0 ms 332 KB Output is correct
43 Correct 0 ms 332 KB Output is correct
44 Execution timed out 1088 ms 4888 KB Time limit exceeded
45 Halted 0 ms 0 KB -