Submission #844678

# Submission time Handle Problem Language Result Execution time Memory
844678 2023-09-05T16:48:06 Z anton Collecting Stamps 3 (JOI20_ho_t3) C++17
25 / 100
992 ms 98732 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long

const int MAX_N = 201;
const int INF = 1e17;
int N, L;
int dp[MAX_N][MAX_N][MAX_N];
int X[MAX_N];
int T[MAX_N];


struct Node{
    int t;

    int cur, other;
    int has;

    Node(int _t, int _cur, int _other, int _has){
        t = _t;
        cur = _cur;
        other = _other;
        has = _has;
    }

    bool operator<(const Node &b)const{
        return t>b.t;
    }
};

vector<Node> gen_neig(Node& cur){
    int left, right;
    left = max(cur.cur, cur.other);
    right = min(cur.cur, cur.other);

    //cout<<left<<" "<<right<<" "<<cur.t<<" "<<cur.has<<endl;

    vector<Node> res;
    if(cur.cur == left){
        if(left>right){
            int new_time = cur.t + ((X[(left+1)%L] - X[left] +L)%L);
            if(new_time<=T[left]){
                res.push_back(Node(new_time, left-1, right, cur.has +1));
            }
            else{
                res.push_back(Node(new_time, left-1, right, cur.has));
            }
            
        }
    }
    if(cur.cur == right){
        if(left>right){
            int new_time = cur.t + abs(X[right]- X[right+1]);
            if(new_time<=T[right+1]){
                res.push_back(Node(new_time, right+1, left, cur.has +1));
            }
            else{
                res.push_back(Node(new_time, right+1, left, cur.has));
            }
        }
    }
    ////cout<<"pos L: "<<X[(left+1)%L]<<endl;
    res.push_back(Node(cur.t + abs( (L - X[(left+1)%L])%L+ X[right]), cur.other, cur.cur, cur.has));
    return res;
}

signed main(){
    cin>>N>>L;
    N++;
    X[0]  =0;

    fill(dp[0][0], dp[MAX_N-1][MAX_N-1], INF);

    T[0]=  INF;
    for(int i = 1; i<N; i++){
        cin>>X[i];
    }

    for(int i = 1; i<N; i++){
        cin>>T[i];
    }


    priority_queue<Node> pq;

    pq.push(Node(0, 0, N-1, 0));
    dp[0][N-1][0] = 0;

    while(pq.size()>0){
        auto cur = pq.top();
        pq.pop();

        ////cout<<cur.cur<<" "<<cur.other<<" "<<cur.has<<" "<<cur.t<<endl;


        if(dp[cur.cur][cur.other][cur.has] == cur.t){
            //cout<<"actual"<<endl;
            auto neigs = gen_neig(cur);
            for(auto v: neigs){
                if(dp[v.cur][v.other][v.has]> v.t){
                    pq.push(v);
                    dp[v.cur][v.other][v.has] = v.t;
                }
            }
        }
        else{
            //cout<<dp[cur.cur][cur.other][cur.has]<<endl;
        }
    }

    int best = 0;
    for(int i = 0; i<N; i++){
        for(int j = 0; j<=N; j++){
            if(dp[i][i][j] <INF){
                best = max(best, j);
            }
        }
    }

    cout<<best<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 63836 KB Output is correct
2 Correct 12 ms 63964 KB Output is correct
3 Correct 12 ms 63836 KB Output is correct
4 Correct 12 ms 63944 KB Output is correct
5 Correct 12 ms 63968 KB Output is correct
6 Correct 12 ms 63836 KB Output is correct
7 Correct 12 ms 63836 KB Output is correct
8 Correct 12 ms 63948 KB Output is correct
9 Correct 12 ms 63832 KB Output is correct
10 Correct 12 ms 63836 KB Output is correct
11 Correct 12 ms 63944 KB Output is correct
12 Correct 12 ms 63836 KB Output is correct
13 Correct 12 ms 63836 KB Output is correct
14 Correct 12 ms 63872 KB Output is correct
15 Correct 12 ms 63836 KB Output is correct
16 Correct 12 ms 63836 KB Output is correct
17 Correct 12 ms 63952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 63836 KB Output is correct
2 Correct 12 ms 63964 KB Output is correct
3 Correct 12 ms 63836 KB Output is correct
4 Correct 12 ms 63944 KB Output is correct
5 Correct 12 ms 63968 KB Output is correct
6 Correct 12 ms 63836 KB Output is correct
7 Correct 12 ms 63836 KB Output is correct
8 Correct 12 ms 63948 KB Output is correct
9 Correct 12 ms 63832 KB Output is correct
10 Correct 12 ms 63836 KB Output is correct
11 Correct 12 ms 63944 KB Output is correct
12 Correct 12 ms 63836 KB Output is correct
13 Correct 12 ms 63836 KB Output is correct
14 Correct 12 ms 63872 KB Output is correct
15 Correct 12 ms 63836 KB Output is correct
16 Correct 12 ms 63836 KB Output is correct
17 Correct 12 ms 63952 KB Output is correct
18 Correct 12 ms 63832 KB Output is correct
19 Correct 12 ms 63836 KB Output is correct
20 Correct 12 ms 63836 KB Output is correct
21 Correct 12 ms 63836 KB Output is correct
22 Correct 12 ms 63836 KB Output is correct
23 Correct 12 ms 63956 KB Output is correct
24 Correct 12 ms 63956 KB Output is correct
25 Correct 12 ms 63836 KB Output is correct
26 Correct 12 ms 63900 KB Output is correct
27 Correct 12 ms 63836 KB Output is correct
28 Correct 12 ms 63968 KB Output is correct
29 Correct 14 ms 63836 KB Output is correct
30 Correct 14 ms 63836 KB Output is correct
31 Correct 12 ms 63836 KB Output is correct
32 Correct 12 ms 63836 KB Output is correct
33 Correct 13 ms 63836 KB Output is correct
34 Correct 12 ms 63932 KB Output is correct
35 Correct 12 ms 63836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 63836 KB Output is correct
2 Correct 12 ms 63964 KB Output is correct
3 Correct 12 ms 63836 KB Output is correct
4 Correct 12 ms 63944 KB Output is correct
5 Correct 12 ms 63968 KB Output is correct
6 Correct 12 ms 63836 KB Output is correct
7 Correct 12 ms 63836 KB Output is correct
8 Correct 12 ms 63948 KB Output is correct
9 Correct 12 ms 63832 KB Output is correct
10 Correct 12 ms 63836 KB Output is correct
11 Correct 12 ms 63944 KB Output is correct
12 Correct 12 ms 63836 KB Output is correct
13 Correct 12 ms 63836 KB Output is correct
14 Correct 12 ms 63872 KB Output is correct
15 Correct 12 ms 63836 KB Output is correct
16 Correct 12 ms 63836 KB Output is correct
17 Correct 12 ms 63952 KB Output is correct
18 Correct 455 ms 80724 KB Output is correct
19 Correct 208 ms 74264 KB Output is correct
20 Correct 65 ms 68292 KB Output is correct
21 Correct 150 ms 73768 KB Output is correct
22 Correct 305 ms 81872 KB Output is correct
23 Correct 34 ms 65992 KB Output is correct
24 Correct 32 ms 66000 KB Output is correct
25 Correct 36 ms 64976 KB Output is correct
26 Correct 19 ms 64472 KB Output is correct
27 Correct 37 ms 66100 KB Output is correct
28 Correct 29 ms 66096 KB Output is correct
29 Correct 57 ms 66084 KB Output is correct
30 Correct 33 ms 66000 KB Output is correct
31 Correct 54 ms 65988 KB Output is correct
32 Correct 28 ms 64980 KB Output is correct
33 Correct 56 ms 65984 KB Output is correct
34 Correct 19 ms 65232 KB Output is correct
35 Correct 22 ms 64504 KB Output is correct
36 Correct 21 ms 64980 KB Output is correct
37 Correct 25 ms 65156 KB Output is correct
38 Correct 26 ms 64976 KB Output is correct
39 Correct 26 ms 64968 KB Output is correct
40 Correct 24 ms 65528 KB Output is correct
41 Correct 690 ms 98316 KB Output is correct
42 Correct 18 ms 64348 KB Output is correct
43 Correct 763 ms 97180 KB Output is correct
44 Correct 18 ms 64348 KB Output is correct
45 Correct 688 ms 97276 KB Output is correct
46 Correct 18 ms 64344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 63836 KB Output is correct
2 Correct 12 ms 63964 KB Output is correct
3 Correct 12 ms 63836 KB Output is correct
4 Correct 12 ms 63944 KB Output is correct
5 Correct 12 ms 63968 KB Output is correct
6 Correct 12 ms 63836 KB Output is correct
7 Correct 12 ms 63836 KB Output is correct
8 Correct 12 ms 63948 KB Output is correct
9 Correct 12 ms 63832 KB Output is correct
10 Correct 12 ms 63836 KB Output is correct
11 Correct 12 ms 63944 KB Output is correct
12 Correct 12 ms 63836 KB Output is correct
13 Correct 12 ms 63836 KB Output is correct
14 Correct 12 ms 63872 KB Output is correct
15 Correct 12 ms 63836 KB Output is correct
16 Correct 12 ms 63836 KB Output is correct
17 Correct 12 ms 63952 KB Output is correct
18 Correct 12 ms 63832 KB Output is correct
19 Correct 12 ms 63836 KB Output is correct
20 Correct 12 ms 63836 KB Output is correct
21 Correct 12 ms 63836 KB Output is correct
22 Correct 12 ms 63836 KB Output is correct
23 Correct 12 ms 63956 KB Output is correct
24 Correct 12 ms 63956 KB Output is correct
25 Correct 12 ms 63836 KB Output is correct
26 Correct 12 ms 63900 KB Output is correct
27 Correct 12 ms 63836 KB Output is correct
28 Correct 12 ms 63968 KB Output is correct
29 Correct 14 ms 63836 KB Output is correct
30 Correct 14 ms 63836 KB Output is correct
31 Correct 12 ms 63836 KB Output is correct
32 Correct 12 ms 63836 KB Output is correct
33 Correct 13 ms 63836 KB Output is correct
34 Correct 12 ms 63932 KB Output is correct
35 Correct 12 ms 63836 KB Output is correct
36 Correct 455 ms 80724 KB Output is correct
37 Correct 208 ms 74264 KB Output is correct
38 Correct 65 ms 68292 KB Output is correct
39 Correct 150 ms 73768 KB Output is correct
40 Correct 305 ms 81872 KB Output is correct
41 Correct 34 ms 65992 KB Output is correct
42 Correct 32 ms 66000 KB Output is correct
43 Correct 36 ms 64976 KB Output is correct
44 Correct 19 ms 64472 KB Output is correct
45 Correct 37 ms 66100 KB Output is correct
46 Correct 29 ms 66096 KB Output is correct
47 Correct 57 ms 66084 KB Output is correct
48 Correct 33 ms 66000 KB Output is correct
49 Correct 54 ms 65988 KB Output is correct
50 Correct 28 ms 64980 KB Output is correct
51 Correct 56 ms 65984 KB Output is correct
52 Correct 19 ms 65232 KB Output is correct
53 Correct 22 ms 64504 KB Output is correct
54 Correct 21 ms 64980 KB Output is correct
55 Correct 25 ms 65156 KB Output is correct
56 Correct 26 ms 64976 KB Output is correct
57 Correct 26 ms 64968 KB Output is correct
58 Correct 24 ms 65528 KB Output is correct
59 Correct 690 ms 98316 KB Output is correct
60 Correct 18 ms 64348 KB Output is correct
61 Correct 763 ms 97180 KB Output is correct
62 Correct 18 ms 64348 KB Output is correct
63 Correct 688 ms 97276 KB Output is correct
64 Correct 18 ms 64344 KB Output is correct
65 Correct 992 ms 97192 KB Output is correct
66 Correct 737 ms 82528 KB Output is correct
67 Correct 496 ms 81544 KB Output is correct
68 Correct 476 ms 80716 KB Output is correct
69 Correct 866 ms 98424 KB Output is correct
70 Correct 289 ms 82348 KB Output is correct
71 Correct 746 ms 96948 KB Output is correct
72 Correct 312 ms 82280 KB Output is correct
73 Correct 342 ms 81680 KB Output is correct
74 Correct 242 ms 72480 KB Output is correct
75 Correct 594 ms 98036 KB Output is correct
76 Correct 495 ms 81252 KB Output is correct
77 Correct 982 ms 98732 KB Output is correct
78 Correct 274 ms 73144 KB Output is correct
79 Correct 693 ms 98048 KB Output is correct
80 Correct 526 ms 82592 KB Output is correct
81 Correct 620 ms 98112 KB Output is correct
82 Correct 272 ms 72624 KB Output is correct
83 Correct 978 ms 97200 KB Output is correct
84 Correct 286 ms 74420 KB Output is correct
85 Correct 528 ms 97732 KB Output is correct
86 Correct 322 ms 72836 KB Output is correct
87 Correct 683 ms 97192 KB Output is correct
88 Incorrect 910 ms 98472 KB Output isn't correct
89 Halted 0 ms 0 KB -