답안 #647331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647331 2022-10-02T08:33:17 Z ck_platypus Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
81 ms 127464 KB
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <cstring>
#include <fstream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define plpll pair<ll, pll>
#define pii pair<int, int>
#define f first
#define s second
#define inf 1000000000000
#define endl '\n'
ll dp[201][201][201][2];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    for(int i=0;i<201;i++) for(int j=0;j<201;j++) for(int k=0;k<201;k++) dp[i][j][k][0]=dp[i][j][k][1]=inf;
    ll n, L;
    int aans=0;
    cin >> n >> L;
    ll x[n], t[n];
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<n;i++) cin >> t[i];
    dp[0][0][0][0]=dp[0][0][0][1]=0;
    dp[0][1][0][1]=x[0];
    dp[0][1][0][0]=2*x[0];
    if(x[0]<=t[0]){
        dp[0][1][1][1]=x[0];
        dp[0][1][1][0]=2*x[0];
    }
    for(int r=2;r<=n;r++){
        dp[0][r][0][1]=x[r-1];
        dp[0][r][0][0]=2*x[r-1];
        for(int ans=1;ans<=r;ans++){
            if(dp[0][r-1][ans-1][1]+x[r-1]-x[r-2]<=t[r-1]) dp[0][r][ans][1]=dp[0][r-1][ans-1][1]+x[r-1]-x[r-2];
            else dp[0][r][ans][1]=dp[0][r-1][ans][1]+x[r-1]-x[r-2];
            dp[0][r][ans][0]=dp[0][r][ans][1]+x[r-1];
        }
    }
    for(int l=1;l<=n;l++){
        if(l==1){
            dp[1][0][0][0]=L-x[n-1];
            dp[1][0][0][1]=2*(L-x[n-1]);
            if(L-x[n-1]<=t[n-1]){
                dp[1][0][1][0]=L-x[n-1];
                dp[1][0][1][1]=2*(L-x[n-1]);
            }
        }else{
            for(int ans=1;ans<=l;ans++){
                if(dp[l-1][0][ans-1][0]+x[n-l+1]-x[n-l]<=t[n-l]) dp[l][0][ans][0]=dp[l-1][0][ans-1][0]+x[n-l+1]-x[n-l];
                else dp[l][0][ans][0]=dp[l-1][0][ans][0]+x[n-l+1]-x[n-l];
                dp[l][0][ans][1]=dp[l][0][ans][0]+L-x[n-l];
            }
        }
        for(int r=1;l+r<=n;r++){
            for(int ans=1;ans<=l+r;ans++){
                if(l==1){
                    if(dp[l-1][r][ans-1][0]+L-x[n-l]<=t[n-l]) dp[l][r][ans][0]=dp[l-1][r][ans-1][0]+L-x[n-l];
                    else dp[l][r][ans][0]=dp[l-1][r][ans][0]+L-x[n-l];
                }else{
                    if(dp[l-1][r][ans-1][0]+x[n-l+1]-x[n-l]<=t[n-l]) dp[l][r][ans][0]=dp[l-1][r][ans-1][0]+x[n-l+1]-x[n-l];
                    else dp[l][r][ans][0]=dp[l-1][r][ans][0]+x[n-l+1]-x[n-l];
                }
                if(r==1){
                    if(dp[l][r-1][ans-1][1]+x[r-1]<=t[r-1]) dp[l][r][ans][1]=dp[l][r-1][ans-1][1]+x[r-1];
                    else dp[l][r][ans][1]=dp[l][r-1][ans][1]+x[r-1];
                }else{
                    if(dp[l][r-1][ans-1][1]+x[r-1]-x[r-2]<=t[r-1]) dp[l][r][ans][1]=dp[l][r-1][ans-1][1]+x[r-1]-x[r-2];
                    else dp[l][r][ans][1]=dp[l][r-1][ans][1]+x[r-1]-x[r-2];
                }
                dp[l][r][ans][0]=min(dp[l][r][ans][0], dp[l][r][ans][1]+x[r-1]+L-x[n-l]);
                dp[l][r][ans][1]=min(dp[l][r][ans][1], dp[l][r][ans][0]+x[r-1]+L-x[n-l]);
            }
        }
    }
    for(int i=0;i<201;i++)
        for(int j=0;j<201;j++)
            for(int k=0;k<201;k++)
                if(dp[i][j][k][0]<inf || dp[i][j][k][1]<inf) aans=max(aans, k);
    cout << aans << endl;
    /*ll a, b;
    while(cin >> a >> b){
        for(int i=1;i<=a+b;i++) cout << dp[a][b][i][0] << " ";cout << endl;
        for(int i=1;i<=a+b;i++) cout << dp[a][b][i][1] << " ";cout << endl;
    }*/
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 127324 KB Output is correct
2 Correct 61 ms 127416 KB Output is correct
3 Correct 60 ms 127332 KB Output is correct
4 Correct 59 ms 127436 KB Output is correct
5 Correct 67 ms 127464 KB Output is correct
6 Correct 70 ms 127432 KB Output is correct
7 Correct 64 ms 127412 KB Output is correct
8 Correct 73 ms 127372 KB Output is correct
9 Correct 61 ms 127404 KB Output is correct
10 Correct 61 ms 127400 KB Output is correct
11 Correct 59 ms 127392 KB Output is correct
12 Correct 60 ms 127388 KB Output is correct
13 Correct 63 ms 127400 KB Output is correct
14 Correct 71 ms 127420 KB Output is correct
15 Correct 59 ms 127404 KB Output is correct
16 Correct 60 ms 127432 KB Output is correct
17 Correct 68 ms 127376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 127324 KB Output is correct
2 Correct 61 ms 127416 KB Output is correct
3 Correct 60 ms 127332 KB Output is correct
4 Correct 59 ms 127436 KB Output is correct
5 Correct 67 ms 127464 KB Output is correct
6 Correct 70 ms 127432 KB Output is correct
7 Correct 64 ms 127412 KB Output is correct
8 Correct 73 ms 127372 KB Output is correct
9 Correct 61 ms 127404 KB Output is correct
10 Correct 61 ms 127400 KB Output is correct
11 Correct 59 ms 127392 KB Output is correct
12 Correct 60 ms 127388 KB Output is correct
13 Correct 63 ms 127400 KB Output is correct
14 Correct 71 ms 127420 KB Output is correct
15 Correct 59 ms 127404 KB Output is correct
16 Correct 60 ms 127432 KB Output is correct
17 Correct 68 ms 127376 KB Output is correct
18 Correct 68 ms 127380 KB Output is correct
19 Correct 64 ms 127400 KB Output is correct
20 Correct 76 ms 127312 KB Output is correct
21 Correct 64 ms 127432 KB Output is correct
22 Correct 62 ms 127432 KB Output is correct
23 Correct 61 ms 127428 KB Output is correct
24 Correct 68 ms 127312 KB Output is correct
25 Correct 66 ms 127400 KB Output is correct
26 Correct 64 ms 127372 KB Output is correct
27 Correct 62 ms 127412 KB Output is correct
28 Correct 65 ms 127332 KB Output is correct
29 Correct 65 ms 127376 KB Output is correct
30 Correct 81 ms 127316 KB Output is correct
31 Correct 61 ms 127324 KB Output is correct
32 Correct 62 ms 127432 KB Output is correct
33 Correct 61 ms 127412 KB Output is correct
34 Correct 61 ms 127348 KB Output is correct
35 Correct 69 ms 127432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 127324 KB Output is correct
2 Correct 61 ms 127416 KB Output is correct
3 Correct 60 ms 127332 KB Output is correct
4 Correct 59 ms 127436 KB Output is correct
5 Correct 67 ms 127464 KB Output is correct
6 Correct 70 ms 127432 KB Output is correct
7 Correct 64 ms 127412 KB Output is correct
8 Correct 73 ms 127372 KB Output is correct
9 Correct 61 ms 127404 KB Output is correct
10 Correct 61 ms 127400 KB Output is correct
11 Correct 59 ms 127392 KB Output is correct
12 Correct 60 ms 127388 KB Output is correct
13 Correct 63 ms 127400 KB Output is correct
14 Correct 71 ms 127420 KB Output is correct
15 Correct 59 ms 127404 KB Output is correct
16 Correct 60 ms 127432 KB Output is correct
17 Correct 68 ms 127376 KB Output is correct
18 Correct 77 ms 127320 KB Output is correct
19 Correct 75 ms 127408 KB Output is correct
20 Correct 64 ms 127312 KB Output is correct
21 Correct 70 ms 127404 KB Output is correct
22 Correct 70 ms 127432 KB Output is correct
23 Correct 68 ms 127432 KB Output is correct
24 Correct 72 ms 127308 KB Output is correct
25 Correct 68 ms 127432 KB Output is correct
26 Incorrect 72 ms 127408 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 127324 KB Output is correct
2 Correct 61 ms 127416 KB Output is correct
3 Correct 60 ms 127332 KB Output is correct
4 Correct 59 ms 127436 KB Output is correct
5 Correct 67 ms 127464 KB Output is correct
6 Correct 70 ms 127432 KB Output is correct
7 Correct 64 ms 127412 KB Output is correct
8 Correct 73 ms 127372 KB Output is correct
9 Correct 61 ms 127404 KB Output is correct
10 Correct 61 ms 127400 KB Output is correct
11 Correct 59 ms 127392 KB Output is correct
12 Correct 60 ms 127388 KB Output is correct
13 Correct 63 ms 127400 KB Output is correct
14 Correct 71 ms 127420 KB Output is correct
15 Correct 59 ms 127404 KB Output is correct
16 Correct 60 ms 127432 KB Output is correct
17 Correct 68 ms 127376 KB Output is correct
18 Correct 68 ms 127380 KB Output is correct
19 Correct 64 ms 127400 KB Output is correct
20 Correct 76 ms 127312 KB Output is correct
21 Correct 64 ms 127432 KB Output is correct
22 Correct 62 ms 127432 KB Output is correct
23 Correct 61 ms 127428 KB Output is correct
24 Correct 68 ms 127312 KB Output is correct
25 Correct 66 ms 127400 KB Output is correct
26 Correct 64 ms 127372 KB Output is correct
27 Correct 62 ms 127412 KB Output is correct
28 Correct 65 ms 127332 KB Output is correct
29 Correct 65 ms 127376 KB Output is correct
30 Correct 81 ms 127316 KB Output is correct
31 Correct 61 ms 127324 KB Output is correct
32 Correct 62 ms 127432 KB Output is correct
33 Correct 61 ms 127412 KB Output is correct
34 Correct 61 ms 127348 KB Output is correct
35 Correct 69 ms 127432 KB Output is correct
36 Correct 77 ms 127320 KB Output is correct
37 Correct 75 ms 127408 KB Output is correct
38 Correct 64 ms 127312 KB Output is correct
39 Correct 70 ms 127404 KB Output is correct
40 Correct 70 ms 127432 KB Output is correct
41 Correct 68 ms 127432 KB Output is correct
42 Correct 72 ms 127308 KB Output is correct
43 Correct 68 ms 127432 KB Output is correct
44 Incorrect 72 ms 127408 KB Output isn't correct
45 Halted 0 ms 0 KB -