답안 #240169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240169 2020-06-18T10:50:43 Z lyc Mountains (IOI17_mountains) C++14
100 / 100
44 ms 16384 KB
#include "mountains.h"
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cout << #x << " :: " << x << endl;
#define _ << " " <<
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

const double EPS = 1e-6;
const int mxN = 2e3+5;
int memo[mxN][mxN];

int solve(int l, int r, vector<int>& y) {
    if (l > r) return 0;
    if (l == r) return 1;
    if (~memo[l][r]) return memo[l][r];
    int mx = l;
    FOR(i,l+1,r) if (y[i] > y[mx]) mx = i;
    memo[l][r] = solve(l,mx-1,y) + solve(mx+1,r,y);
    int cur = 1;
    if (l < mx-1) {
        int j = mx-2;
        double mng = (double)(y[mx]-y[mx-1]);
        RFOR(i,mx-2,l){
            double g = (double)(y[mx]-y[i])/(mx-i);
            if (g < mng+EPS) {
                mng = g;
                cur += solve(i+1,j,y);
                j = i-1;
            }
        }
        cur += solve(l,j,y);
    }
    if (mx+1 < r) {
        int j = mx+2;
        double mng = (double)(y[mx]-y[mx+1]);
        FOR(i,mx+2,r){
            double g = (double)(y[mx]-y[i])/(i-mx);
            if (g < mng+EPS) {
                mng = g;
                cur += solve(j,i-1,y);
                j = i+1;
            }
        }
        cur += solve(j,r,y);
    }
    memo[l][r] = max(memo[l][r],cur);
    return memo[l][r];
}

int maximum_deevs(vector<int> y) {
    memset(memo,-1,sizeof memo);
	return solve(0,SZ(y)-1,y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16128 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 12 ms 16000 KB Output is correct
4 Correct 12 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 13 ms 16000 KB Output is correct
7 Correct 13 ms 16000 KB Output is correct
8 Correct 12 ms 16128 KB Output is correct
9 Correct 14 ms 16000 KB Output is correct
10 Correct 12 ms 16000 KB Output is correct
11 Correct 12 ms 16000 KB Output is correct
12 Correct 12 ms 16000 KB Output is correct
13 Correct 12 ms 16000 KB Output is correct
14 Correct 12 ms 16000 KB Output is correct
15 Correct 14 ms 16000 KB Output is correct
16 Correct 14 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16128 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 12 ms 16000 KB Output is correct
4 Correct 12 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 13 ms 16000 KB Output is correct
7 Correct 13 ms 16000 KB Output is correct
8 Correct 12 ms 16128 KB Output is correct
9 Correct 14 ms 16000 KB Output is correct
10 Correct 12 ms 16000 KB Output is correct
11 Correct 12 ms 16000 KB Output is correct
12 Correct 12 ms 16000 KB Output is correct
13 Correct 12 ms 16000 KB Output is correct
14 Correct 12 ms 16000 KB Output is correct
15 Correct 14 ms 16000 KB Output is correct
16 Correct 14 ms 16000 KB Output is correct
17 Correct 13 ms 16000 KB Output is correct
18 Correct 14 ms 16000 KB Output is correct
19 Correct 12 ms 16000 KB Output is correct
20 Correct 14 ms 16000 KB Output is correct
21 Correct 14 ms 16000 KB Output is correct
22 Correct 14 ms 16000 KB Output is correct
23 Correct 13 ms 16000 KB Output is correct
24 Correct 12 ms 16000 KB Output is correct
25 Correct 13 ms 16000 KB Output is correct
26 Correct 14 ms 16000 KB Output is correct
27 Correct 14 ms 16128 KB Output is correct
28 Correct 13 ms 16000 KB Output is correct
29 Correct 13 ms 16128 KB Output is correct
30 Correct 14 ms 16000 KB Output is correct
31 Correct 12 ms 16000 KB Output is correct
32 Correct 13 ms 16000 KB Output is correct
33 Correct 15 ms 16000 KB Output is correct
34 Correct 14 ms 16000 KB Output is correct
35 Correct 13 ms 16000 KB Output is correct
36 Correct 13 ms 16000 KB Output is correct
37 Correct 14 ms 16000 KB Output is correct
38 Correct 13 ms 16128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16128 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 12 ms 16000 KB Output is correct
4 Correct 12 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 13 ms 16000 KB Output is correct
7 Correct 13 ms 16000 KB Output is correct
8 Correct 12 ms 16128 KB Output is correct
9 Correct 14 ms 16000 KB Output is correct
10 Correct 12 ms 16000 KB Output is correct
11 Correct 12 ms 16000 KB Output is correct
12 Correct 12 ms 16000 KB Output is correct
13 Correct 12 ms 16000 KB Output is correct
14 Correct 12 ms 16000 KB Output is correct
15 Correct 14 ms 16000 KB Output is correct
16 Correct 14 ms 16000 KB Output is correct
17 Correct 13 ms 16000 KB Output is correct
18 Correct 14 ms 16000 KB Output is correct
19 Correct 12 ms 16000 KB Output is correct
20 Correct 14 ms 16000 KB Output is correct
21 Correct 14 ms 16000 KB Output is correct
22 Correct 14 ms 16000 KB Output is correct
23 Correct 13 ms 16000 KB Output is correct
24 Correct 12 ms 16000 KB Output is correct
25 Correct 13 ms 16000 KB Output is correct
26 Correct 14 ms 16000 KB Output is correct
27 Correct 14 ms 16128 KB Output is correct
28 Correct 13 ms 16000 KB Output is correct
29 Correct 13 ms 16128 KB Output is correct
30 Correct 14 ms 16000 KB Output is correct
31 Correct 12 ms 16000 KB Output is correct
32 Correct 13 ms 16000 KB Output is correct
33 Correct 15 ms 16000 KB Output is correct
34 Correct 14 ms 16000 KB Output is correct
35 Correct 13 ms 16000 KB Output is correct
36 Correct 13 ms 16000 KB Output is correct
37 Correct 14 ms 16000 KB Output is correct
38 Correct 13 ms 16128 KB Output is correct
39 Correct 14 ms 16000 KB Output is correct
40 Correct 15 ms 16000 KB Output is correct
41 Correct 13 ms 16000 KB Output is correct
42 Correct 15 ms 16000 KB Output is correct
43 Correct 12 ms 16000 KB Output is correct
44 Correct 14 ms 16000 KB Output is correct
45 Correct 13 ms 16000 KB Output is correct
46 Correct 13 ms 16128 KB Output is correct
47 Correct 13 ms 16128 KB Output is correct
48 Correct 15 ms 16128 KB Output is correct
49 Correct 13 ms 16128 KB Output is correct
50 Correct 13 ms 16128 KB Output is correct
51 Correct 13 ms 16000 KB Output is correct
52 Correct 15 ms 16128 KB Output is correct
53 Correct 14 ms 16128 KB Output is correct
54 Correct 14 ms 16128 KB Output is correct
55 Correct 15 ms 16256 KB Output is correct
56 Correct 16 ms 16256 KB Output is correct
57 Correct 13 ms 16128 KB Output is correct
58 Correct 13 ms 16128 KB Output is correct
59 Correct 15 ms 16128 KB Output is correct
60 Correct 13 ms 16128 KB Output is correct
61 Correct 14 ms 16128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16128 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 12 ms 16000 KB Output is correct
4 Correct 12 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 13 ms 16000 KB Output is correct
7 Correct 13 ms 16000 KB Output is correct
8 Correct 12 ms 16128 KB Output is correct
9 Correct 14 ms 16000 KB Output is correct
10 Correct 12 ms 16000 KB Output is correct
11 Correct 12 ms 16000 KB Output is correct
12 Correct 12 ms 16000 KB Output is correct
13 Correct 12 ms 16000 KB Output is correct
14 Correct 12 ms 16000 KB Output is correct
15 Correct 14 ms 16000 KB Output is correct
16 Correct 14 ms 16000 KB Output is correct
17 Correct 13 ms 16000 KB Output is correct
18 Correct 14 ms 16000 KB Output is correct
19 Correct 12 ms 16000 KB Output is correct
20 Correct 14 ms 16000 KB Output is correct
21 Correct 14 ms 16000 KB Output is correct
22 Correct 14 ms 16000 KB Output is correct
23 Correct 13 ms 16000 KB Output is correct
24 Correct 12 ms 16000 KB Output is correct
25 Correct 13 ms 16000 KB Output is correct
26 Correct 14 ms 16000 KB Output is correct
27 Correct 14 ms 16128 KB Output is correct
28 Correct 13 ms 16000 KB Output is correct
29 Correct 13 ms 16128 KB Output is correct
30 Correct 14 ms 16000 KB Output is correct
31 Correct 12 ms 16000 KB Output is correct
32 Correct 13 ms 16000 KB Output is correct
33 Correct 15 ms 16000 KB Output is correct
34 Correct 14 ms 16000 KB Output is correct
35 Correct 13 ms 16000 KB Output is correct
36 Correct 13 ms 16000 KB Output is correct
37 Correct 14 ms 16000 KB Output is correct
38 Correct 13 ms 16128 KB Output is correct
39 Correct 14 ms 16000 KB Output is correct
40 Correct 15 ms 16000 KB Output is correct
41 Correct 13 ms 16000 KB Output is correct
42 Correct 15 ms 16000 KB Output is correct
43 Correct 12 ms 16000 KB Output is correct
44 Correct 14 ms 16000 KB Output is correct
45 Correct 13 ms 16000 KB Output is correct
46 Correct 13 ms 16128 KB Output is correct
47 Correct 13 ms 16128 KB Output is correct
48 Correct 15 ms 16128 KB Output is correct
49 Correct 13 ms 16128 KB Output is correct
50 Correct 13 ms 16128 KB Output is correct
51 Correct 13 ms 16000 KB Output is correct
52 Correct 15 ms 16128 KB Output is correct
53 Correct 14 ms 16128 KB Output is correct
54 Correct 14 ms 16128 KB Output is correct
55 Correct 15 ms 16256 KB Output is correct
56 Correct 16 ms 16256 KB Output is correct
57 Correct 13 ms 16128 KB Output is correct
58 Correct 13 ms 16128 KB Output is correct
59 Correct 15 ms 16128 KB Output is correct
60 Correct 13 ms 16128 KB Output is correct
61 Correct 14 ms 16128 KB Output is correct
62 Correct 14 ms 16000 KB Output is correct
63 Correct 13 ms 16128 KB Output is correct
64 Correct 14 ms 16128 KB Output is correct
65 Correct 13 ms 16128 KB Output is correct
66 Correct 13 ms 16128 KB Output is correct
67 Correct 13 ms 16128 KB Output is correct
68 Correct 13 ms 16128 KB Output is correct
69 Correct 13 ms 16128 KB Output is correct
70 Correct 21 ms 16256 KB Output is correct
71 Correct 21 ms 16256 KB Output is correct
72 Correct 22 ms 16256 KB Output is correct
73 Correct 23 ms 16128 KB Output is correct
74 Correct 23 ms 16248 KB Output is correct
75 Correct 21 ms 16128 KB Output is correct
76 Correct 13 ms 16128 KB Output is correct
77 Correct 42 ms 16256 KB Output is correct
78 Correct 39 ms 16256 KB Output is correct
79 Correct 44 ms 16256 KB Output is correct
80 Correct 44 ms 16384 KB Output is correct
81 Correct 39 ms 16256 KB Output is correct
82 Correct 25 ms 16384 KB Output is correct
83 Correct 26 ms 16128 KB Output is correct
84 Correct 24 ms 16256 KB Output is correct
85 Correct 23 ms 16376 KB Output is correct
86 Correct 25 ms 16256 KB Output is correct