답안 #680914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680914 2023-01-12T03:12:10 Z uylulu Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
240 ms 66848 KB
#include <bits/stdc++.h>
using namespace std;

#define double long double
// #define int long long
#define endl "\n"

const int N = 200 + 3,oo = 2e9;

int dp[N + 1][N + 1][N + 1][2];

int x[N + 1],t[N + 1];

int n,len;

int f(int l,int r,int cnt,int side) {
    if(l == n + 1 && r == 0) {
        if(cnt != 0) {
            return oo;
        }
        return 0;
    }

    // cout<<cnt<<endl;

    if(dp[l][r][cnt][side] != -1) return dp[l][r][cnt][side];

    int res = oo;

    // cout<<l<<" "<<r<<" "<<cnt<<endl;

    if(side == 1) {
        if(r > 0) {
            res = min(res,f(l,r - 1,cnt,1) + (x[r] - x[r - 1]));
            res = min(res,f(l,r - 1,cnt,0) + (len - x[l]) + x[r]);
        }
    
        if(r > 0 && cnt > 0) {
            int tl = f(l,r - 1,cnt - 1,1);

            if(t[r] >= tl + (x[r] - x[r - 1])) {
                res = min(res,tl + x[r] - x[r - 1]);
            }

            tl = f(l,r - 1,cnt - 1,0);

            if(t[r] >= tl + (len - x[l]) + x[r]) {
                res = min(res,tl + (len - x[l]) + x[r]);
            }
        }
        return dp[l][r][cnt][side] = res;
    } else {
        if(l <= n) {
            res = min(res,f(l + 1,r,cnt,0) + abs(x[l] - x[l + 1]));
            res = min(res,f(l + 1,r,cnt,1) + (len - x[l]) + x[r]);
        }
        if(l <= n && cnt > 0) {
            int tl = f(l + 1,r,cnt - 1,0);

            if(t[l] >= tl + abs(x[l] - x[l + 1])) {
                res = min(res,tl + abs(x[l] - x[l + 1]));
            }
            tl = f(l + 1,r,cnt - 1,1);

            if(t[l] >= tl + (len - x[l]) + x[r]) {
                res = min(res,tl + (len - x[l]) + x[r]);
            }
        }
        return dp[l][r][cnt][side] = res;
    }
    return dp[l][r][cnt][side] = oo;
}

signed main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);

    memset(dp,-1,sizeof(dp));

    cin>>n>>len;

    for(int i = 1;i <= n;i++) {
        cin>>x[i];
    }
    for(int i = 1;i <= n;i++) {
        cin>>t[i];
    }
    int res = 0;

    if(x[n] == len) {
        res++;
        n--;
    }
    x[0] = 0;
    x[n + 1] = len;

    int sum = 0;

    // cout<<f(0,4,7,1)<<endl;

    for(int i = 0;i <= n;i++) {
        for(int j = i + 1;j <= n + 1;j++) {
            for(int k = 0;k <= n;k++) {
                int asd = min(f(j,i,k,0),f(j,i,k,1));

                if(asd < oo) {
                    sum = max(sum,k);
                    // cout<<j<<" "<<i<<" "<<k<<endl;
                }

            }
        }
    }
    cout<<res + sum<<endl;

    return 0;
}       
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 66704 KB Output is correct
2 Correct 27 ms 66712 KB Output is correct
3 Correct 26 ms 66732 KB Output is correct
4 Correct 27 ms 66772 KB Output is correct
5 Correct 27 ms 66704 KB Output is correct
6 Correct 29 ms 66764 KB Output is correct
7 Correct 26 ms 66772 KB Output is correct
8 Correct 27 ms 66644 KB Output is correct
9 Correct 28 ms 66720 KB Output is correct
10 Correct 28 ms 66672 KB Output is correct
11 Correct 26 ms 66680 KB Output is correct
12 Correct 27 ms 66772 KB Output is correct
13 Correct 28 ms 66720 KB Output is correct
14 Correct 27 ms 66704 KB Output is correct
15 Correct 28 ms 66752 KB Output is correct
16 Correct 34 ms 66636 KB Output is correct
17 Correct 27 ms 66716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 66704 KB Output is correct
2 Correct 27 ms 66712 KB Output is correct
3 Correct 26 ms 66732 KB Output is correct
4 Correct 27 ms 66772 KB Output is correct
5 Correct 27 ms 66704 KB Output is correct
6 Correct 29 ms 66764 KB Output is correct
7 Correct 26 ms 66772 KB Output is correct
8 Correct 27 ms 66644 KB Output is correct
9 Correct 28 ms 66720 KB Output is correct
10 Correct 28 ms 66672 KB Output is correct
11 Correct 26 ms 66680 KB Output is correct
12 Correct 27 ms 66772 KB Output is correct
13 Correct 28 ms 66720 KB Output is correct
14 Correct 27 ms 66704 KB Output is correct
15 Correct 28 ms 66752 KB Output is correct
16 Correct 34 ms 66636 KB Output is correct
17 Correct 27 ms 66716 KB Output is correct
18 Incorrect 30 ms 66760 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 66704 KB Output is correct
2 Correct 27 ms 66712 KB Output is correct
3 Correct 26 ms 66732 KB Output is correct
4 Correct 27 ms 66772 KB Output is correct
5 Correct 27 ms 66704 KB Output is correct
6 Correct 29 ms 66764 KB Output is correct
7 Correct 26 ms 66772 KB Output is correct
8 Correct 27 ms 66644 KB Output is correct
9 Correct 28 ms 66720 KB Output is correct
10 Correct 28 ms 66672 KB Output is correct
11 Correct 26 ms 66680 KB Output is correct
12 Correct 27 ms 66772 KB Output is correct
13 Correct 28 ms 66720 KB Output is correct
14 Correct 27 ms 66704 KB Output is correct
15 Correct 28 ms 66752 KB Output is correct
16 Correct 34 ms 66636 KB Output is correct
17 Correct 27 ms 66716 KB Output is correct
18 Correct 218 ms 66772 KB Output is correct
19 Correct 112 ms 66768 KB Output is correct
20 Correct 55 ms 66772 KB Output is correct
21 Correct 105 ms 66788 KB Output is correct
22 Correct 124 ms 66772 KB Output is correct
23 Correct 49 ms 66760 KB Output is correct
24 Correct 44 ms 66644 KB Output is correct
25 Correct 47 ms 66676 KB Output is correct
26 Correct 31 ms 66636 KB Output is correct
27 Correct 63 ms 66772 KB Output is correct
28 Correct 39 ms 66772 KB Output is correct
29 Correct 50 ms 66696 KB Output is correct
30 Correct 43 ms 66760 KB Output is correct
31 Correct 50 ms 66760 KB Output is correct
32 Correct 37 ms 66668 KB Output is correct
33 Correct 49 ms 66708 KB Output is correct
34 Correct 36 ms 66636 KB Output is correct
35 Correct 44 ms 66764 KB Output is correct
36 Correct 34 ms 66848 KB Output is correct
37 Correct 51 ms 66764 KB Output is correct
38 Correct 36 ms 66728 KB Output is correct
39 Correct 50 ms 66680 KB Output is correct
40 Correct 36 ms 66680 KB Output is correct
41 Correct 235 ms 66784 KB Output is correct
42 Correct 144 ms 66768 KB Output is correct
43 Correct 240 ms 66772 KB Output is correct
44 Correct 136 ms 66772 KB Output is correct
45 Correct 236 ms 66708 KB Output is correct
46 Correct 150 ms 66768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 66704 KB Output is correct
2 Correct 27 ms 66712 KB Output is correct
3 Correct 26 ms 66732 KB Output is correct
4 Correct 27 ms 66772 KB Output is correct
5 Correct 27 ms 66704 KB Output is correct
6 Correct 29 ms 66764 KB Output is correct
7 Correct 26 ms 66772 KB Output is correct
8 Correct 27 ms 66644 KB Output is correct
9 Correct 28 ms 66720 KB Output is correct
10 Correct 28 ms 66672 KB Output is correct
11 Correct 26 ms 66680 KB Output is correct
12 Correct 27 ms 66772 KB Output is correct
13 Correct 28 ms 66720 KB Output is correct
14 Correct 27 ms 66704 KB Output is correct
15 Correct 28 ms 66752 KB Output is correct
16 Correct 34 ms 66636 KB Output is correct
17 Correct 27 ms 66716 KB Output is correct
18 Incorrect 30 ms 66760 KB Output isn't correct
19 Halted 0 ms 0 KB -