Submission #285489

# Submission time Handle Problem Language Result Execution time Memory
285489 2020-08-29T07:07:09 Z HynDuf Mountains (IOI17_mountains) C++14
100 / 100
41 ms 14336 KB
#include <bits/stdc++.h>
#include "mountains.h"
#define task "M"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 2003;
int dp[N][N];
bool can_reach(ii &A, ii &B, ii &C) // Line AC is not cut by B - A->B->C must go in counter clockwise order (A.x < B.x < C.x)
{
    return ((B.F - A.F) * 1LL * (C.S - A.S) - (C.F - A.F) * 1LL * (B.S - A.S)) >= 0;
}
int maximum_deevs(vi a)
{
    int n = SZ(a);
    vii aa;
    rep(i, 0, n - 1) aa.eb(i, a[i]);
    rep(r, 0, n - 1)
    {
        int lst = r, sum = 0; // the minimum index in [l, r] that lst can see r, .i.e. lst and r cannot be chose together
        dp[r][r] = 1;
        Rep(l, r - 1, 0)
        {
            dp[l][r] = dp[l][r - 1];
            if (can_reach(aa[l], aa[lst], aa[r]))
            {
                sum += dp[l + 1][lst - 1];
                lst = l;
            }
            dp[l][r] = max(dp[l][r], 1 + sum + dp[l][lst - 1]);
        }
    }
    return dp[0][n - 1];
}

//int main()
//{
//#ifdef HynDuf
//    freopen(task".in", "r", stdin);
//    //freopen(task".out", "w", stdout);
//#else
//    ios_base::sync_with_stdio(false); cin.tie(nullptr);
//#endif
//    int n;
//    vi a;
//    cin >> n;
//    rep(i, 1, n)
//    {
//        int x;
//        cin >> x;
//        a.eb(x);
//    }
//    cout << maximum_deevs(a);
//    return 0;
//}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 416 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 416 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 416 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 1152 KB Output is correct
40 Correct 2 ms 1664 KB Output is correct
41 Correct 2 ms 1664 KB Output is correct
42 Correct 2 ms 1664 KB Output is correct
43 Correct 1 ms 1664 KB Output is correct
44 Correct 2 ms 1664 KB Output is correct
45 Correct 2 ms 1664 KB Output is correct
46 Correct 2 ms 1656 KB Output is correct
47 Correct 2 ms 1664 KB Output is correct
48 Correct 1 ms 1664 KB Output is correct
49 Correct 2 ms 1664 KB Output is correct
50 Correct 2 ms 1664 KB Output is correct
51 Correct 1 ms 1664 KB Output is correct
52 Correct 2 ms 1664 KB Output is correct
53 Correct 1 ms 1664 KB Output is correct
54 Correct 2 ms 1664 KB Output is correct
55 Correct 1 ms 1664 KB Output is correct
56 Correct 2 ms 1664 KB Output is correct
57 Correct 2 ms 1664 KB Output is correct
58 Correct 1 ms 1664 KB Output is correct
59 Correct 1 ms 1664 KB Output is correct
60 Correct 1 ms 1664 KB Output is correct
61 Correct 2 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 416 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 1152 KB Output is correct
40 Correct 2 ms 1664 KB Output is correct
41 Correct 2 ms 1664 KB Output is correct
42 Correct 2 ms 1664 KB Output is correct
43 Correct 1 ms 1664 KB Output is correct
44 Correct 2 ms 1664 KB Output is correct
45 Correct 2 ms 1664 KB Output is correct
46 Correct 2 ms 1656 KB Output is correct
47 Correct 2 ms 1664 KB Output is correct
48 Correct 1 ms 1664 KB Output is correct
49 Correct 2 ms 1664 KB Output is correct
50 Correct 2 ms 1664 KB Output is correct
51 Correct 1 ms 1664 KB Output is correct
52 Correct 2 ms 1664 KB Output is correct
53 Correct 1 ms 1664 KB Output is correct
54 Correct 2 ms 1664 KB Output is correct
55 Correct 1 ms 1664 KB Output is correct
56 Correct 2 ms 1664 KB Output is correct
57 Correct 2 ms 1664 KB Output is correct
58 Correct 1 ms 1664 KB Output is correct
59 Correct 1 ms 1664 KB Output is correct
60 Correct 1 ms 1664 KB Output is correct
61 Correct 2 ms 1664 KB Output is correct
62 Correct 6 ms 6272 KB Output is correct
63 Correct 28 ms 14200 KB Output is correct
64 Correct 29 ms 14200 KB Output is correct
65 Correct 28 ms 14232 KB Output is correct
66 Correct 28 ms 14208 KB Output is correct
67 Correct 29 ms 14208 KB Output is correct
68 Correct 28 ms 14200 KB Output is correct
69 Correct 28 ms 14200 KB Output is correct
70 Correct 40 ms 14200 KB Output is correct
71 Correct 34 ms 14200 KB Output is correct
72 Correct 34 ms 14156 KB Output is correct
73 Correct 34 ms 14336 KB Output is correct
74 Correct 36 ms 14200 KB Output is correct
75 Correct 35 ms 14328 KB Output is correct
76 Correct 29 ms 14208 KB Output is correct
77 Correct 39 ms 14200 KB Output is correct
78 Correct 41 ms 14204 KB Output is correct
79 Correct 40 ms 14208 KB Output is correct
80 Correct 40 ms 14200 KB Output is correct
81 Correct 39 ms 14140 KB Output is correct
82 Correct 28 ms 14200 KB Output is correct
83 Correct 29 ms 14208 KB Output is correct
84 Correct 29 ms 14200 KB Output is correct
85 Correct 28 ms 14232 KB Output is correct
86 Correct 28 ms 14208 KB Output is correct