Submission #747785

# Submission time Handle Problem Language Result Execution time Memory
747785 2023-05-24T17:23:24 Z prairie2022 Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
169 ms 5868 KB
#include <bits/stdc++.h>
typedef long long ll;
#define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define vst vis[tmp.b][tmp.w[0]][tmp.w[1]]
using namespace std;

const int M = 1e9;
int n, L, ans=0;
int x[2][201], d[2][201];
int vis[2][201][201];

struct dp{
    int t, c, w[2];
    bool b;
    inline bool forward(){
        if(w[0]+w[1]==n) return 0;
        w[b]++;
        t += x[b][w[b]]-x[b][w[b]-1];
        if(t>M) return 0;
        if(t<=d[b][w[b]]) c++;
        return 1;
    }
    inline bool backward(){
        if(w[0]+w[1]==n) return 0;
        b = !b;
        w[b]++;
        t += x[b][w[b]]+x[!b][w[!b]];
        if(t>M) return 0;
        if(t<=d[b][w[b]]) c++;
        return 1;
    }
};

inline bool cmp(dp dp1, dp dp2){
    return dp1.t > dp2.t;
}

priority_queue<dp, vector<dp>, decltype(&cmp)> pq(cmp);

int main(){
    dp tmp, ins;
    for(int i=0; i<201; i++){
        fill(vis[0][i], vis[0][i]+201, -1);
        fill(vis[1][i], vis[1][i]+201, -1);
    }
    fastio
    //informations
    cin >> n >> L;
    x[0][0] = x[1][0] = 0;
    for(int i=1; i<=n; i++){
        cin >> x[0][i];
        x[1][n+1-i] = L-x[0][i];
    }
    for(int i=1; i<=n; i++){
        cin >> d[0][i];
        d[1][n+1-i] = d[0][i];
    }
    //dp
    pq.push({0, 0, {0, 0}, 0});
    while(!pq.empty() && pq.top().t<=M){
        tmp = pq.top();
        pq.pop();
        //cout << tmp.t << ' ' << tmp.c << ' ' << tmp.w[0] << ' ' << tmp.w[1] << ' ' << (int)tmp.b << '\n';
        if(tmp.c<=vst) continue;
        vst = tmp.c;
        ans = max(ans, tmp.c);
        ins = tmp;
        if(ins.forward()) pq.push(ins);
        ins = tmp;
        if(ins.backward()) pq.push(ins);
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 644 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 644 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 644 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 644 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 636 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 636 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 640 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 644 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 644 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 63 ms 3248 KB Output is correct
19 Correct 29 ms 1424 KB Output is correct
20 Correct 14 ms 1424 KB Output is correct
21 Correct 25 ms 1424 KB Output is correct
22 Correct 42 ms 2048 KB Output is correct
23 Correct 17 ms 1340 KB Output is correct
24 Correct 22 ms 1996 KB Output is correct
25 Correct 22 ms 1424 KB Output is correct
26 Correct 4 ms 852 KB Output is correct
27 Correct 19 ms 1424 KB Output is correct
28 Correct 16 ms 1424 KB Output is correct
29 Correct 12 ms 996 KB Output is correct
30 Correct 22 ms 1996 KB Output is correct
31 Correct 11 ms 1076 KB Output is correct
32 Correct 9 ms 1076 KB Output is correct
33 Correct 12 ms 1076 KB Output is correct
34 Correct 8 ms 1424 KB Output is correct
35 Correct 10 ms 1060 KB Output is correct
36 Correct 10 ms 1340 KB Output is correct
37 Correct 13 ms 1088 KB Output is correct
38 Correct 10 ms 1076 KB Output is correct
39 Correct 11 ms 1040 KB Output is correct
40 Correct 12 ms 1424 KB Output is correct
41 Correct 164 ms 5848 KB Output is correct
42 Correct 9 ms 1076 KB Output is correct
43 Correct 169 ms 5868 KB Output is correct
44 Correct 10 ms 996 KB Output is correct
45 Correct 152 ms 5812 KB Output is correct
46 Correct 10 ms 1076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 644 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 644 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 636 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 636 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 640 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 596 KB Output is correct
36 Correct 63 ms 3248 KB Output is correct
37 Correct 29 ms 1424 KB Output is correct
38 Correct 14 ms 1424 KB Output is correct
39 Correct 25 ms 1424 KB Output is correct
40 Correct 42 ms 2048 KB Output is correct
41 Correct 17 ms 1340 KB Output is correct
42 Correct 22 ms 1996 KB Output is correct
43 Correct 22 ms 1424 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 19 ms 1424 KB Output is correct
46 Correct 16 ms 1424 KB Output is correct
47 Correct 12 ms 996 KB Output is correct
48 Correct 22 ms 1996 KB Output is correct
49 Correct 11 ms 1076 KB Output is correct
50 Correct 9 ms 1076 KB Output is correct
51 Correct 12 ms 1076 KB Output is correct
52 Correct 8 ms 1424 KB Output is correct
53 Correct 10 ms 1060 KB Output is correct
54 Correct 10 ms 1340 KB Output is correct
55 Correct 13 ms 1088 KB Output is correct
56 Correct 10 ms 1076 KB Output is correct
57 Correct 11 ms 1040 KB Output is correct
58 Correct 12 ms 1424 KB Output is correct
59 Correct 164 ms 5848 KB Output is correct
60 Correct 9 ms 1076 KB Output is correct
61 Correct 169 ms 5868 KB Output is correct
62 Correct 10 ms 996 KB Output is correct
63 Correct 152 ms 5812 KB Output is correct
64 Correct 10 ms 1076 KB Output is correct
65 Correct 13 ms 1076 KB Output is correct
66 Correct 9 ms 904 KB Output is correct
67 Correct 8 ms 852 KB Output is correct
68 Correct 9 ms 852 KB Output is correct
69 Correct 11 ms 1076 KB Output is correct
70 Correct 64 ms 3312 KB Output is correct
71 Correct 6 ms 596 KB Output is correct
72 Correct 38 ms 1984 KB Output is correct
73 Correct 2 ms 596 KB Output is correct
74 Correct 48 ms 2016 KB Output is correct
75 Correct 5 ms 724 KB Output is correct
76 Correct 70 ms 2040 KB Output is correct
77 Correct 7 ms 724 KB Output is correct
78 Correct 34 ms 1996 KB Output is correct
79 Correct 15 ms 1076 KB Output is correct
80 Correct 50 ms 1956 KB Output is correct
81 Correct 4 ms 724 KB Output is correct
82 Correct 46 ms 2076 KB Output is correct
83 Correct 13 ms 852 KB Output is correct
84 Correct 43 ms 2048 KB Output is correct
85 Correct 2 ms 636 KB Output is correct
86 Correct 51 ms 2036 KB Output is correct
87 Correct 18 ms 1000 KB Output is correct
88 Correct 24 ms 1076 KB Output is correct
89 Correct 8 ms 852 KB Output is correct
90 Correct 7 ms 852 KB Output is correct
91 Correct 24 ms 1076 KB Output is correct
92 Correct 9 ms 884 KB Output is correct
93 Correct 6 ms 852 KB Output is correct