답안 #220701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
220701 2020-04-08T12:32:11 Z srvlt Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
155 ms 131448 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 203;
ll n, l, x[N], t[N];
ll dp[2][N][N][N];

void upd(ll & x, ll y) {
    x = min(x, y);
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
    }
    memset(& dp, 0x3f, sizeof(dp));
    ll inf = dp[0][0][0][0];
    dp[0][0][0][0] = dp[1][0][0][0] = 0;
    int res = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; i + j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                if (dp[0][i][j][k] < inf) {
                    if (i < n) {
                        ll val = dp[0][i][j][k] + min(x[i + 1] - x[i], l - (x[i + 1] - x[i]));
                        upd(dp[0][i + 1][j][k + (t[i + 1] >= val)], val);
                    }
                    if (j < n) {
                        ll d = abs(x[n - j] - x[i]);
                        ll val = dp[0][i][j][k] + min(d, l - d);
                        upd(dp[1][i][j + 1][k + (t[n - j] >= val)], val);
                    }
                    res = max(res, k);
                }
                if (dp[1][i][j][k] < inf) {
                    if (i < n) {
                        ll d = abs(x[i + 1] - x[(n - j + 1) % (n + 1)]);
                        ll val = dp[1][i][j][k] + min(d, l - d);
                        upd(dp[0][i + 1][j][k + (t[i + 1] >= val)], val);
                    }
                    if (j < n) {
                        ll d = abs(x[n - j] - x[(n - j + 1) % (n + 1)]);
                        ll val = dp[1][i][j][k] + min(d, l - d);
                        upd(dp[1][i][j + 1][k + (t[n - j] >= val)], val);
                    }
                    res = max(res, k);
                }
            }
        }
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 131356 KB Output is correct
2 Correct 75 ms 131312 KB Output is correct
3 Correct 81 ms 131320 KB Output is correct
4 Correct 73 ms 131320 KB Output is correct
5 Correct 74 ms 131320 KB Output is correct
6 Correct 81 ms 131424 KB Output is correct
7 Correct 75 ms 131320 KB Output is correct
8 Correct 81 ms 131400 KB Output is correct
9 Correct 74 ms 131320 KB Output is correct
10 Correct 75 ms 131320 KB Output is correct
11 Correct 80 ms 131320 KB Output is correct
12 Correct 77 ms 131320 KB Output is correct
13 Correct 72 ms 131320 KB Output is correct
14 Correct 74 ms 131324 KB Output is correct
15 Correct 74 ms 131320 KB Output is correct
16 Correct 75 ms 131320 KB Output is correct
17 Correct 74 ms 131320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 131356 KB Output is correct
2 Correct 75 ms 131312 KB Output is correct
3 Correct 81 ms 131320 KB Output is correct
4 Correct 73 ms 131320 KB Output is correct
5 Correct 74 ms 131320 KB Output is correct
6 Correct 81 ms 131424 KB Output is correct
7 Correct 75 ms 131320 KB Output is correct
8 Correct 81 ms 131400 KB Output is correct
9 Correct 74 ms 131320 KB Output is correct
10 Correct 75 ms 131320 KB Output is correct
11 Correct 80 ms 131320 KB Output is correct
12 Correct 77 ms 131320 KB Output is correct
13 Correct 72 ms 131320 KB Output is correct
14 Correct 74 ms 131324 KB Output is correct
15 Correct 74 ms 131320 KB Output is correct
16 Correct 75 ms 131320 KB Output is correct
17 Correct 74 ms 131320 KB Output is correct
18 Correct 77 ms 131320 KB Output is correct
19 Correct 75 ms 131320 KB Output is correct
20 Correct 74 ms 131320 KB Output is correct
21 Correct 74 ms 131320 KB Output is correct
22 Correct 73 ms 131324 KB Output is correct
23 Correct 78 ms 131320 KB Output is correct
24 Correct 75 ms 131320 KB Output is correct
25 Correct 76 ms 131320 KB Output is correct
26 Correct 74 ms 131320 KB Output is correct
27 Correct 89 ms 131320 KB Output is correct
28 Correct 72 ms 131324 KB Output is correct
29 Correct 74 ms 131320 KB Output is correct
30 Correct 77 ms 131320 KB Output is correct
31 Correct 74 ms 131320 KB Output is correct
32 Correct 72 ms 131320 KB Output is correct
33 Correct 76 ms 131312 KB Output is correct
34 Correct 77 ms 131320 KB Output is correct
35 Correct 77 ms 131320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 131356 KB Output is correct
2 Correct 75 ms 131312 KB Output is correct
3 Correct 81 ms 131320 KB Output is correct
4 Correct 73 ms 131320 KB Output is correct
5 Correct 74 ms 131320 KB Output is correct
6 Correct 81 ms 131424 KB Output is correct
7 Correct 75 ms 131320 KB Output is correct
8 Correct 81 ms 131400 KB Output is correct
9 Correct 74 ms 131320 KB Output is correct
10 Correct 75 ms 131320 KB Output is correct
11 Correct 80 ms 131320 KB Output is correct
12 Correct 77 ms 131320 KB Output is correct
13 Correct 72 ms 131320 KB Output is correct
14 Correct 74 ms 131324 KB Output is correct
15 Correct 74 ms 131320 KB Output is correct
16 Correct 75 ms 131320 KB Output is correct
17 Correct 74 ms 131320 KB Output is correct
18 Correct 114 ms 131320 KB Output is correct
19 Correct 103 ms 131320 KB Output is correct
20 Correct 82 ms 131320 KB Output is correct
21 Correct 94 ms 131320 KB Output is correct
22 Correct 103 ms 131324 KB Output is correct
23 Correct 83 ms 131320 KB Output is correct
24 Correct 81 ms 131320 KB Output is correct
25 Correct 82 ms 131320 KB Output is correct
26 Correct 84 ms 131448 KB Output is correct
27 Correct 84 ms 131320 KB Output is correct
28 Correct 74 ms 131320 KB Output is correct
29 Correct 82 ms 131312 KB Output is correct
30 Correct 75 ms 131316 KB Output is correct
31 Correct 85 ms 131356 KB Output is correct
32 Correct 76 ms 131320 KB Output is correct
33 Correct 80 ms 131320 KB Output is correct
34 Correct 74 ms 131320 KB Output is correct
35 Correct 78 ms 131320 KB Output is correct
36 Correct 76 ms 131320 KB Output is correct
37 Correct 83 ms 131320 KB Output is correct
38 Correct 78 ms 131324 KB Output is correct
39 Correct 80 ms 131320 KB Output is correct
40 Correct 76 ms 131320 KB Output is correct
41 Correct 139 ms 131320 KB Output is correct
42 Correct 78 ms 131324 KB Output is correct
43 Correct 138 ms 131356 KB Output is correct
44 Correct 92 ms 131324 KB Output is correct
45 Correct 154 ms 131356 KB Output is correct
46 Correct 91 ms 131320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 131356 KB Output is correct
2 Correct 75 ms 131312 KB Output is correct
3 Correct 81 ms 131320 KB Output is correct
4 Correct 73 ms 131320 KB Output is correct
5 Correct 74 ms 131320 KB Output is correct
6 Correct 81 ms 131424 KB Output is correct
7 Correct 75 ms 131320 KB Output is correct
8 Correct 81 ms 131400 KB Output is correct
9 Correct 74 ms 131320 KB Output is correct
10 Correct 75 ms 131320 KB Output is correct
11 Correct 80 ms 131320 KB Output is correct
12 Correct 77 ms 131320 KB Output is correct
13 Correct 72 ms 131320 KB Output is correct
14 Correct 74 ms 131324 KB Output is correct
15 Correct 74 ms 131320 KB Output is correct
16 Correct 75 ms 131320 KB Output is correct
17 Correct 74 ms 131320 KB Output is correct
18 Correct 77 ms 131320 KB Output is correct
19 Correct 75 ms 131320 KB Output is correct
20 Correct 74 ms 131320 KB Output is correct
21 Correct 74 ms 131320 KB Output is correct
22 Correct 73 ms 131324 KB Output is correct
23 Correct 78 ms 131320 KB Output is correct
24 Correct 75 ms 131320 KB Output is correct
25 Correct 76 ms 131320 KB Output is correct
26 Correct 74 ms 131320 KB Output is correct
27 Correct 89 ms 131320 KB Output is correct
28 Correct 72 ms 131324 KB Output is correct
29 Correct 74 ms 131320 KB Output is correct
30 Correct 77 ms 131320 KB Output is correct
31 Correct 74 ms 131320 KB Output is correct
32 Correct 72 ms 131320 KB Output is correct
33 Correct 76 ms 131312 KB Output is correct
34 Correct 77 ms 131320 KB Output is correct
35 Correct 77 ms 131320 KB Output is correct
36 Correct 114 ms 131320 KB Output is correct
37 Correct 103 ms 131320 KB Output is correct
38 Correct 82 ms 131320 KB Output is correct
39 Correct 94 ms 131320 KB Output is correct
40 Correct 103 ms 131324 KB Output is correct
41 Correct 83 ms 131320 KB Output is correct
42 Correct 81 ms 131320 KB Output is correct
43 Correct 82 ms 131320 KB Output is correct
44 Correct 84 ms 131448 KB Output is correct
45 Correct 84 ms 131320 KB Output is correct
46 Correct 74 ms 131320 KB Output is correct
47 Correct 82 ms 131312 KB Output is correct
48 Correct 75 ms 131316 KB Output is correct
49 Correct 85 ms 131356 KB Output is correct
50 Correct 76 ms 131320 KB Output is correct
51 Correct 80 ms 131320 KB Output is correct
52 Correct 74 ms 131320 KB Output is correct
53 Correct 78 ms 131320 KB Output is correct
54 Correct 76 ms 131320 KB Output is correct
55 Correct 83 ms 131320 KB Output is correct
56 Correct 78 ms 131324 KB Output is correct
57 Correct 80 ms 131320 KB Output is correct
58 Correct 76 ms 131320 KB Output is correct
59 Correct 139 ms 131320 KB Output is correct
60 Correct 78 ms 131324 KB Output is correct
61 Correct 138 ms 131356 KB Output is correct
62 Correct 92 ms 131324 KB Output is correct
63 Correct 154 ms 131356 KB Output is correct
64 Correct 91 ms 131320 KB Output is correct
65 Correct 134 ms 131356 KB Output is correct
66 Correct 121 ms 131320 KB Output is correct
67 Correct 121 ms 131320 KB Output is correct
68 Correct 117 ms 131360 KB Output is correct
69 Correct 125 ms 131320 KB Output is correct
70 Correct 129 ms 131324 KB Output is correct
71 Correct 119 ms 131320 KB Output is correct
72 Correct 132 ms 131320 KB Output is correct
73 Correct 102 ms 131320 KB Output is correct
74 Correct 127 ms 131320 KB Output is correct
75 Correct 116 ms 131320 KB Output is correct
76 Correct 144 ms 131448 KB Output is correct
77 Correct 130 ms 131296 KB Output is correct
78 Correct 121 ms 131320 KB Output is correct
79 Correct 119 ms 131320 KB Output is correct
80 Correct 142 ms 131320 KB Output is correct
81 Correct 109 ms 131320 KB Output is correct
82 Correct 104 ms 131320 KB Output is correct
83 Correct 130 ms 131320 KB Output is correct
84 Correct 106 ms 131320 KB Output is correct
85 Correct 115 ms 131448 KB Output is correct
86 Correct 110 ms 131320 KB Output is correct
87 Correct 123 ms 131320 KB Output is correct
88 Correct 155 ms 131320 KB Output is correct
89 Correct 144 ms 131448 KB Output is correct
90 Correct 80 ms 131320 KB Output is correct
91 Correct 155 ms 131320 KB Output is correct
92 Correct 131 ms 131320 KB Output is correct
93 Correct 83 ms 131320 KB Output is correct