답안 #299838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299838 2020-09-15T19:20:54 Z MarcoMeijer Mountains (IOI17_mountains) C++14
100 / 100
44 ms 16256 KB
#include "mountains.h"
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define RE(a,b) REP(a,0,b)
#define FOR(a,b) for(auto& a:b)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
 
const int INF=1e9;
const int MX=1e5;
const ld EPS=1e-17;
 
int cross(ii a, ii b) {return a.fi*b.se - b.se*a.fi;}
bool ccw(ii a, ii b) {return cross(a,b) >= 0;}
ii subt(ii a, ii b) {return {a.fi-b.fi, a.se-b.se};}
bool ccw(ii A, ii B, ii C) {
    return ((B.fi - A.fi) * 1LL * (C.se - A.se) - (C.fi - A.fi) * 1LL * (B.se - A.se)) >= 0;
}

int maximum_deevs(vi y) {
    int n = y.size();
    vii C;
    RE(i,n) C.pb({i,y[i]});

    vector<vi> dp; dp.assign(n,vi(n,0));
    RE(i,n) dp[i][i] = 1;
    RE(r,n) {
        int last=r, sm=0;
        REV(l,0,r) {
            dp[l][r] = dp[l][r-1];

            if(ccw(C[l],C[last],C[r])) {
                sm += last ? dp[l+1][last-1] : 0;
                last = l;
            }

            dp[l][r] = max(dp[l][r], 1 + sm + (last ? dp[l][last-1] : 0));
        }
    }

	return dp[0][n-1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 288 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 0 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 288 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 0 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 676 KB Output is correct
41 Correct 1 ms 640 KB Output is correct
42 Correct 1 ms 768 KB Output is correct
43 Correct 2 ms 640 KB Output is correct
44 Correct 1 ms 640 KB Output is correct
45 Correct 1 ms 640 KB Output is correct
46 Correct 1 ms 640 KB Output is correct
47 Correct 1 ms 640 KB Output is correct
48 Correct 1 ms 640 KB Output is correct
49 Correct 1 ms 640 KB Output is correct
50 Correct 1 ms 640 KB Output is correct
51 Correct 1 ms 640 KB Output is correct
52 Correct 1 ms 640 KB Output is correct
53 Correct 1 ms 640 KB Output is correct
54 Correct 1 ms 640 KB Output is correct
55 Correct 1 ms 640 KB Output is correct
56 Correct 1 ms 640 KB Output is correct
57 Correct 1 ms 640 KB Output is correct
58 Correct 1 ms 640 KB Output is correct
59 Correct 1 ms 640 KB Output is correct
60 Correct 1 ms 640 KB Output is correct
61 Correct 1 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 288 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 0 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 676 KB Output is correct
41 Correct 1 ms 640 KB Output is correct
42 Correct 1 ms 768 KB Output is correct
43 Correct 2 ms 640 KB Output is correct
44 Correct 1 ms 640 KB Output is correct
45 Correct 1 ms 640 KB Output is correct
46 Correct 1 ms 640 KB Output is correct
47 Correct 1 ms 640 KB Output is correct
48 Correct 1 ms 640 KB Output is correct
49 Correct 1 ms 640 KB Output is correct
50 Correct 1 ms 640 KB Output is correct
51 Correct 1 ms 640 KB Output is correct
52 Correct 1 ms 640 KB Output is correct
53 Correct 1 ms 640 KB Output is correct
54 Correct 1 ms 640 KB Output is correct
55 Correct 1 ms 640 KB Output is correct
56 Correct 1 ms 640 KB Output is correct
57 Correct 1 ms 640 KB Output is correct
58 Correct 1 ms 640 KB Output is correct
59 Correct 1 ms 640 KB Output is correct
60 Correct 1 ms 640 KB Output is correct
61 Correct 1 ms 640 KB Output is correct
62 Correct 6 ms 4352 KB Output is correct
63 Correct 32 ms 16128 KB Output is correct
64 Correct 33 ms 16128 KB Output is correct
65 Correct 32 ms 16128 KB Output is correct
66 Correct 32 ms 16128 KB Output is correct
67 Correct 33 ms 16128 KB Output is correct
68 Correct 32 ms 16128 KB Output is correct
69 Correct 32 ms 16128 KB Output is correct
70 Correct 36 ms 16248 KB Output is correct
71 Correct 37 ms 16128 KB Output is correct
72 Correct 40 ms 16128 KB Output is correct
73 Correct 38 ms 16256 KB Output is correct
74 Correct 37 ms 16128 KB Output is correct
75 Correct 39 ms 16128 KB Output is correct
76 Correct 35 ms 16128 KB Output is correct
77 Correct 43 ms 16256 KB Output is correct
78 Correct 43 ms 16128 KB Output is correct
79 Correct 42 ms 16128 KB Output is correct
80 Correct 44 ms 16128 KB Output is correct
81 Correct 41 ms 16128 KB Output is correct
82 Correct 31 ms 16256 KB Output is correct
83 Correct 35 ms 16128 KB Output is correct
84 Correct 35 ms 16128 KB Output is correct
85 Correct 31 ms 16128 KB Output is correct
86 Correct 32 ms 16128 KB Output is correct