답안 #680905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680905 2023-01-12T02:21:26 Z bachhoangxuan Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
60 ms 33936 KB
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define pii pair<int,int>
const int inf=1000000005;
const int mod=998244353;
const int maxn=205;
const int maxl=20;
const int maxa=1000005;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
int dp[maxn][maxn][maxn][2],n,L,x[maxn],t[maxn];
void solve(){
    cin >> n >> L;x[n+1]=L;
    for(int i=1;i<=n;i++) cin >> x[i];
    for(int i=1;i<=n;i++) cin >> t[i];
    for(int i=0;i<=n+1;i++){
        for(int l=0;l<=n+1-i;l++){
            int r=l+i;
            for(int k=0;k<=n+1-i;k++){
                for(int j=0;j<=1;j++) dp[l][r][k][j]=inf;
            }
        }
    }
    dp[0][n+1][0][0]=dp[0][n+1][0][1]=0;
    int res=0;
    for(int i=n+1;i>=1;i--){
        for(int l=0;l<=n+1-i;l++){
            int r=l+i;
            for(int k=0;k<=n+1-i;k++){
                int nxt0=dp[l][r][k][0],nxt1=dp[l][r][k][1];
                if(nxt0!=inf){
                    res=max(res,k);
                    int ok0=x[l+1]-x[l]+nxt0,ok1=x[l]+x[n+1]-x[r-1]+nxt0;
                    dp[l+1][r][k+(ok0<=t[l+1])][0]=min(dp[l+1][r][k+(ok0<=t[l+1])][0],ok0);
                    dp[l][r-1][k+(ok1<=t[r-1])][1]=min(dp[l][r-1][k+(ok1<=t[r-1])][1],ok1);
                }
                if(nxt1!=inf){
                    res=max(res,k);
                    int ok0=x[l+1]+x[n+1]-x[r]+nxt1,ok1=x[r]-x[r-1]+nxt1;
                    dp[l+1][r][k+(ok0<=t[l+1])][0]=min(dp[l+1][r][k+(ok0<=t[l+1])][0],ok0);
                    dp[l][r-1][k+(ok1<=t[r-1])][1]=min(dp[l][r-1][k+(ok1<=t[r-1])][1],ok1);
                }
            }
        }
    }
    cout << res << '\n';
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t=1;//cin >> t;
    while(t--) solve();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 596 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 0 ms 340 KB Output is correct
28 Correct 1 ms 468 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 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 596 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 40 ms 27340 KB Output is correct
19 Correct 22 ms 16760 KB Output is correct
20 Correct 10 ms 9260 KB Output is correct
21 Correct 20 ms 15952 KB Output is correct
22 Correct 30 ms 20504 KB Output is correct
23 Correct 9 ms 7952 KB Output is correct
24 Correct 6 ms 6224 KB Output is correct
25 Correct 8 ms 7764 KB Output is correct
26 Correct 2 ms 3156 KB Output is correct
27 Correct 9 ms 8020 KB Output is correct
28 Correct 4 ms 5844 KB Output is correct
29 Correct 9 ms 8268 KB Output is correct
30 Correct 6 ms 6484 KB Output is correct
31 Correct 8 ms 7764 KB Output is correct
32 Correct 3 ms 4308 KB Output is correct
33 Correct 7 ms 7764 KB Output is correct
34 Correct 2 ms 3028 KB Output is correct
35 Correct 5 ms 7636 KB Output is correct
36 Correct 3 ms 3796 KB Output is correct
37 Correct 7 ms 8012 KB Output is correct
38 Correct 4 ms 4652 KB Output is correct
39 Correct 7 ms 8428 KB Output is correct
40 Correct 4 ms 5076 KB Output is correct
41 Correct 60 ms 33592 KB Output is correct
42 Correct 14 ms 22740 KB Output is correct
43 Correct 58 ms 33492 KB Output is correct
44 Correct 15 ms 22612 KB Output is correct
45 Correct 58 ms 33492 KB Output is correct
46 Correct 16 ms 22784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 596 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 0 ms 340 KB Output is correct
28 Correct 1 ms 468 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 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 596 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 552 KB Output is correct
36 Correct 40 ms 27340 KB Output is correct
37 Correct 22 ms 16760 KB Output is correct
38 Correct 10 ms 9260 KB Output is correct
39 Correct 20 ms 15952 KB Output is correct
40 Correct 30 ms 20504 KB Output is correct
41 Correct 9 ms 7952 KB Output is correct
42 Correct 6 ms 6224 KB Output is correct
43 Correct 8 ms 7764 KB Output is correct
44 Correct 2 ms 3156 KB Output is correct
45 Correct 9 ms 8020 KB Output is correct
46 Correct 4 ms 5844 KB Output is correct
47 Correct 9 ms 8268 KB Output is correct
48 Correct 6 ms 6484 KB Output is correct
49 Correct 8 ms 7764 KB Output is correct
50 Correct 3 ms 4308 KB Output is correct
51 Correct 7 ms 7764 KB Output is correct
52 Correct 2 ms 3028 KB Output is correct
53 Correct 5 ms 7636 KB Output is correct
54 Correct 3 ms 3796 KB Output is correct
55 Correct 7 ms 8012 KB Output is correct
56 Correct 4 ms 4652 KB Output is correct
57 Correct 7 ms 8428 KB Output is correct
58 Correct 4 ms 5076 KB Output is correct
59 Correct 60 ms 33592 KB Output is correct
60 Correct 14 ms 22740 KB Output is correct
61 Correct 58 ms 33492 KB Output is correct
62 Correct 15 ms 22612 KB Output is correct
63 Correct 58 ms 33492 KB Output is correct
64 Correct 16 ms 22784 KB Output is correct
65 Correct 22 ms 30420 KB Output is correct
66 Correct 25 ms 27976 KB Output is correct
67 Correct 24 ms 26808 KB Output is correct
68 Correct 19 ms 24776 KB Output is correct
69 Correct 23 ms 30104 KB Output is correct
70 Correct 23 ms 28884 KB Output is correct
71 Correct 18 ms 29140 KB Output is correct
72 Correct 23 ms 29396 KB Output is correct
73 Correct 18 ms 27328 KB Output is correct
74 Correct 22 ms 25556 KB Output is correct
75 Correct 18 ms 28268 KB Output is correct
76 Correct 35 ms 32212 KB Output is correct
77 Correct 22 ms 32212 KB Output is correct
78 Correct 25 ms 25044 KB Output is correct
79 Correct 19 ms 25940 KB Output is correct
80 Correct 34 ms 31632 KB Output is correct
81 Correct 17 ms 26148 KB Output is correct
82 Correct 24 ms 27604 KB Output is correct
83 Correct 26 ms 33604 KB Output is correct
84 Correct 29 ms 28756 KB Output is correct
85 Correct 21 ms 31284 KB Output is correct
86 Correct 30 ms 30712 KB Output is correct
87 Correct 19 ms 28256 KB Output is correct
88 Correct 32 ms 33812 KB Output is correct
89 Correct 25 ms 33924 KB Output is correct
90 Correct 18 ms 28500 KB Output is correct
91 Correct 27 ms 33932 KB Output is correct
92 Correct 24 ms 33936 KB Output is correct
93 Correct 23 ms 33320 KB Output is correct