답안 #745570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745570 2023-05-20T11:45:46 Z Pacybwoah Collecting Stamps 3 (JOI20_ho_t3) C++14
25 / 100
2000 ms 442444 KB
#pragma GCC optimize("O3","unroll-loops")
#include<iostream>
#include<vector>
#include<cassert>
#include<algorithm>
#define ll long long
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll l;
    cin>>n>>l;
    vector<ll> pos(n+1),t(n+1);
    for(int i=1;i<=n;i++) cin>>pos[i];
    for(int i=1;i<=n;i++) cin>>t[i];
    vector<vector<vector<vector<ll>>>> dp(n+1,vector<vector<vector<ll>>>(n+1,vector<vector<ll>>(n+1,vector<ll>(2,1e18))));
    dp[0][0][0][0]=0;
    dp[0][0][0][1]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k+=(k!=0?1:j+1)){
                for(int r=j-1;r>=0;r--){
                    if(dp[i-1][r][k][0]+pos[j]-pos[r]<=t[j]){
                        dp[i][j][k][0]=min(dp[i][j][k][0],dp[i-1][r][k][0]+pos[j]-pos[r]);
                    }
                    if(dp[i-1][r][k][1]+pos[j]+l-pos[k]<=t[j]){
                        dp[i][j][k][0]=min(dp[i][j][k][0],dp[i-1][r][k][1]+pos[j]+l-pos[k]);
                    }
                }
                for(int r=k+1;r<=n;r++){
                    if(dp[i-1][j][r][1]+pos[r]-pos[k]<=t[k]){
                        //if(i==1&&j==0&&k==1) cout<<dp[i-1][j][r][0]+pos[j]+l-pos[k]<<" "<<t[k]<<"\n";
                        dp[i][j][k][1]=min(dp[i][j][k][1],dp[i-1][j][r][1]+pos[r]-pos[k]);
                    }
                    if(dp[i-1][j][r][0]+pos[j]+l-pos[k]<=t[k]){
                        //if(i==1&&j==0&&k==1) cout<<dp[i-1][j][r][0]+pos[j]+l-pos[k]<<" "<<t[k]<<"\n";
                        dp[i][j][k][1]=min(dp[i][j][k][1],dp[i-1][j][r][0]+pos[j]+l-pos[k]);
                    }
                }
                if(dp[i-1][j][0][1]+pos[0]+l-pos[k]<=t[k]){
                    //if(i==1&&j==0&&k==1) cout<<dp[i-1][j][0][0]+pos[j]+l-pos[k]<<" "<<t[k]<<"\n";
                    dp[i][j][k][1]=min(dp[i][j][k][1],dp[i-1][j][0][1]+pos[0]+l-pos[k]);
                }
                if(dp[i-1][j][0][0]+pos[j]+l-pos[k]<=t[k]){
                    //if(i==1&&j==0&&k==1) cout<<"hehe"<<dp[i-1][j][0][0]+pos[j]+l-pos[k]<<" "<<t[k]<<"\n";
                    dp[i][j][k][1]=min(dp[i][j][k][1],dp[i-1][j][0][0]+pos[j]+l-pos[k]);
                }
            }
        }
    }
    for(int i=n;i>=0;i--){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                for(int r=0;r<=1;r++){
                    if(dp[i][j][k][r]<1e18){
                        cout<<i;
                        return 0;
                    }
                }
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 448 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 448 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 576 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 448 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1159 ms 322932 KB Output is correct
19 Correct 473 ms 152572 KB Output is correct
20 Correct 159 ms 59444 KB Output is correct
21 Correct 471 ms 139940 KB Output is correct
22 Correct 697 ms 206436 KB Output is correct
23 Correct 160 ms 46636 KB Output is correct
24 Correct 69 ms 32160 KB Output is correct
25 Correct 151 ms 45024 KB Output is correct
26 Correct 25 ms 10748 KB Output is correct
27 Correct 171 ms 48072 KB Output is correct
28 Correct 61 ms 28964 KB Output is correct
29 Correct 131 ms 49656 KB Output is correct
30 Correct 77 ms 34544 KB Output is correct
31 Correct 112 ms 45128 KB Output is correct
32 Correct 33 ms 17108 KB Output is correct
33 Correct 116 ms 45136 KB Output is correct
34 Correct 21 ms 9700 KB Output is correct
35 Correct 105 ms 43768 KB Output is correct
36 Correct 27 ms 14312 KB Output is correct
37 Correct 113 ms 48076 KB Output is correct
38 Correct 43 ms 19568 KB Output is correct
39 Correct 120 ms 51128 KB Output is correct
40 Correct 47 ms 23024 KB Output is correct
41 Correct 1907 ms 442444 KB Output is correct
42 Correct 797 ms 244556 KB Output is correct
43 Correct 1909 ms 442440 KB Output is correct
44 Correct 801 ms 239912 KB Output is correct
45 Correct 1921 ms 442440 KB Output is correct
46 Correct 788 ms 244544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 448 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 576 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1159 ms 322932 KB Output is correct
37 Correct 473 ms 152572 KB Output is correct
38 Correct 159 ms 59444 KB Output is correct
39 Correct 471 ms 139940 KB Output is correct
40 Correct 697 ms 206436 KB Output is correct
41 Correct 160 ms 46636 KB Output is correct
42 Correct 69 ms 32160 KB Output is correct
43 Correct 151 ms 45024 KB Output is correct
44 Correct 25 ms 10748 KB Output is correct
45 Correct 171 ms 48072 KB Output is correct
46 Correct 61 ms 28964 KB Output is correct
47 Correct 131 ms 49656 KB Output is correct
48 Correct 77 ms 34544 KB Output is correct
49 Correct 112 ms 45128 KB Output is correct
50 Correct 33 ms 17108 KB Output is correct
51 Correct 116 ms 45136 KB Output is correct
52 Correct 21 ms 9700 KB Output is correct
53 Correct 105 ms 43768 KB Output is correct
54 Correct 27 ms 14312 KB Output is correct
55 Correct 113 ms 48076 KB Output is correct
56 Correct 43 ms 19568 KB Output is correct
57 Correct 120 ms 51128 KB Output is correct
58 Correct 47 ms 23024 KB Output is correct
59 Correct 1907 ms 442444 KB Output is correct
60 Correct 797 ms 244556 KB Output is correct
61 Correct 1909 ms 442440 KB Output is correct
62 Correct 801 ms 239912 KB Output is correct
63 Correct 1921 ms 442440 KB Output is correct
64 Correct 788 ms 244544 KB Output is correct
65 Correct 1443 ms 379560 KB Output is correct
66 Correct 1211 ms 333772 KB Output is correct
67 Correct 1168 ms 312332 KB Output is correct
68 Correct 910 ms 276824 KB Output is correct
69 Correct 1377 ms 373336 KB Output is correct
70 Execution timed out 2004 ms 350212 KB Time limit exceeded
71 Halted 0 ms 0 KB -