Submission #172766

# Submission time Handle Problem Language Result Execution time Memory
172766 2020-01-02T14:45:21 Z gs18103 Mountains (IOI17_mountains) C++14
100 / 100
139 ms 14024 KB
#include "mountains.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define em emplace
#define fi first
#define se second
#define all(v) v.begin(), v.end()
 
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int MAX = 2020;
const int INF = 1<<30;
const ll LINF = 1LL<<62;
 
int dp[MAX][MAX];
ll h[MAX];
 
int f(int s, int e) {
    if(s > e) return 0;
    if(dp[s][e] != 0) return dp[s][e];
    dp[s][e] = 1;
    pll high = make_pair(h[s+1] - h[s], 1);
    int idx = s + 1;
    for(int i = s + 2; i <= e; i++) {
        if((h[i] - h[s]) * high.se >= high.fi * (i - s)) {
            dp[s][e] += f(idx+1, i-1);
            idx = i;
            high = make_pair(h[i] - h[s], i - s);
        }
    }
    dp[s][e] += f(idx+1, e);
	dp[s][e] = max(dp[s][e], f(s+1, e));
	return dp[s][e];
}
 
int maximum_deevs(vector <int> y) {
	int n = y.size();
    for(int i = 1; i <= n; i++) {
        h[i] = y[i-1];
    }
   return f(1, n);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 508 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 508 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 2 ms 508 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 2 ms 404 KB Output is correct
34 Correct 2 ms 508 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 508 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 508 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 2 ms 508 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 2 ms 404 KB Output is correct
34 Correct 2 ms 508 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 3 ms 1144 KB Output is correct
40 Correct 4 ms 1656 KB Output is correct
41 Correct 4 ms 1656 KB Output is correct
42 Correct 4 ms 1684 KB Output is correct
43 Correct 4 ms 1656 KB Output is correct
44 Correct 4 ms 1656 KB Output is correct
45 Correct 4 ms 1656 KB Output is correct
46 Correct 4 ms 1656 KB Output is correct
47 Correct 4 ms 1660 KB Output is correct
48 Correct 4 ms 1656 KB Output is correct
49 Correct 4 ms 1656 KB Output is correct
50 Correct 4 ms 1656 KB Output is correct
51 Correct 4 ms 1784 KB Output is correct
52 Correct 4 ms 1784 KB Output is correct
53 Correct 4 ms 1656 KB Output is correct
54 Correct 4 ms 1784 KB Output is correct
55 Correct 4 ms 1656 KB Output is correct
56 Correct 4 ms 1656 KB Output is correct
57 Correct 4 ms 1532 KB Output is correct
58 Correct 4 ms 1656 KB Output is correct
59 Correct 4 ms 1656 KB Output is correct
60 Correct 4 ms 1528 KB Output is correct
61 Correct 4 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 508 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 508 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 2 ms 508 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 2 ms 404 KB Output is correct
34 Correct 2 ms 508 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 3 ms 1144 KB Output is correct
40 Correct 4 ms 1656 KB Output is correct
41 Correct 4 ms 1656 KB Output is correct
42 Correct 4 ms 1684 KB Output is correct
43 Correct 4 ms 1656 KB Output is correct
44 Correct 4 ms 1656 KB Output is correct
45 Correct 4 ms 1656 KB Output is correct
46 Correct 4 ms 1656 KB Output is correct
47 Correct 4 ms 1660 KB Output is correct
48 Correct 4 ms 1656 KB Output is correct
49 Correct 4 ms 1656 KB Output is correct
50 Correct 4 ms 1656 KB Output is correct
51 Correct 4 ms 1784 KB Output is correct
52 Correct 4 ms 1784 KB Output is correct
53 Correct 4 ms 1656 KB Output is correct
54 Correct 4 ms 1784 KB Output is correct
55 Correct 4 ms 1656 KB Output is correct
56 Correct 4 ms 1656 KB Output is correct
57 Correct 4 ms 1532 KB Output is correct
58 Correct 4 ms 1656 KB Output is correct
59 Correct 4 ms 1656 KB Output is correct
60 Correct 4 ms 1528 KB Output is correct
61 Correct 4 ms 1528 KB Output is correct
62 Correct 10 ms 6264 KB Output is correct
63 Correct 16 ms 13308 KB Output is correct
64 Correct 20 ms 12280 KB Output is correct
65 Correct 21 ms 12408 KB Output is correct
66 Correct 21 ms 12444 KB Output is correct
67 Correct 21 ms 12408 KB Output is correct
68 Correct 21 ms 12536 KB Output is correct
69 Correct 19 ms 12536 KB Output is correct
70 Correct 139 ms 13944 KB Output is correct
71 Correct 112 ms 13560 KB Output is correct
72 Correct 115 ms 13532 KB Output is correct
73 Correct 109 ms 13944 KB Output is correct
74 Correct 111 ms 13688 KB Output is correct
75 Correct 123 ms 14024 KB Output is correct
76 Correct 21 ms 12920 KB Output is correct
77 Correct 24 ms 8824 KB Output is correct
78 Correct 24 ms 8824 KB Output is correct
79 Correct 23 ms 8824 KB Output is correct
80 Correct 24 ms 8824 KB Output is correct
81 Correct 25 ms 8828 KB Output is correct
82 Correct 20 ms 8444 KB Output is correct
83 Correct 29 ms 13304 KB Output is correct
84 Correct 31 ms 12792 KB Output is correct
85 Correct 19 ms 8568 KB Output is correct
86 Correct 19 ms 8696 KB Output is correct