답안 #475937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475937 2021-09-24T13:25:01 Z ymm Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
1026 ms 290296 KB
///
///   Let the voice of love take you higher!
///

#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x, l, r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef          __int128    ll;
typedef unsigned long long  ull;
typedef std::pair<int,int>  pii;
typedef std::pair<ll ,ll >  pll;
using namespace std;

#define int ll

const int N = 210;
ll dp[2][N][N][N]; // d, cnt, l, r
ll len, _x[N], *x = _x+1;
ll _t[N], *t = _t+1;
int n;

ll dis(int i, int j)
{
    if(x[j] < x[i]) swap(i, j);
    return min(x[j]-x[i], len-(x[j]-x[i]));
}

bool gd(int i, int j, ll t)
{
    //if(dis(i,j)+t <= ::t[j]) cerr << i << ' ' << j << ' ' << t << '\n';
    return dis(i,j)+t <= ::t[j];
}

void smin(ll& x, ll y){x = min(x, y);}

signed main()
{
    FAST;
    long long _n, _len;
    cin >> _n >> _len;
    n = _n; len = _len;
    Loop(i,0,n) {long long z; cin >> z; x[i] = z;}
    x[n] = x[0]; x[-1] = x[n-1];
    Loop(i,0,n) {long long z; cin >> z; t[i] = z;}
    t[n] = t[0]; t[-1] = t[n-1];
    ll inf = 1; inf <<= 100;
    Loop(a,0,2)Loop(b,0,N)Loop(c,0,N)Loop(d,0,N)
        dp[a][b][c][d] = inf;
    dp[0][t[0  ]>=    x[  0]][1][n  ] =     x[  0];
    dp[1][t[0  ]>=    x[  0]][1][n  ] =     x[  0];
    dp[0][t[n-1]>=len-x[n-1]][0][n-1] = len-x[n-1];
    dp[1][t[n-1]>=len-x[n-1]][0][n-1] = len-x[n-1];
    LoopR(k,1,n)
    {
        Loop(l,0,n)
        {
            int r = l+k;
            Loop(cnt,0,n)
            {
                smin(dp[0][cnt+gd(l-1,l  ,dp[0][cnt][l][r])][l+1][r], dp[0][cnt][l][r]+dis(l-1,l  ));
                smin(dp[1][cnt+gd(l-1,r-1,dp[0][cnt][l][r])][l][r-1], dp[0][cnt][l][r]+dis(l-1,r-1));
                smin(dp[0][cnt+gd(r  ,l  ,dp[1][cnt][l][r])][l+1][r], dp[1][cnt][l][r]+dis(r  ,l  ));
                smin(dp[1][cnt+gd(r  ,r-1,dp[1][cnt][l][r])][l][r-1], dp[1][cnt][l][r]+dis(r  ,r-1));
            }
        }
    }
    int ans = 0;
    Loop(i,0,n) Loop(cnt,ans+1,N)
    {
        if(dp[0][cnt][i][i] != inf) ans = cnt;
        if(dp[1][cnt][i][i] != inf) ans = cnt;
    }
    cout << signed(ans) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 290196 KB Output is correct
2 Correct 122 ms 290152 KB Output is correct
3 Correct 139 ms 290216 KB Output is correct
4 Correct 114 ms 290296 KB Output is correct
5 Correct 121 ms 290244 KB Output is correct
6 Correct 114 ms 290204 KB Output is correct
7 Correct 119 ms 290176 KB Output is correct
8 Correct 137 ms 290156 KB Output is correct
9 Correct 134 ms 290236 KB Output is correct
10 Correct 133 ms 290160 KB Output is correct
11 Correct 124 ms 290240 KB Output is correct
12 Correct 117 ms 290212 KB Output is correct
13 Correct 135 ms 290196 KB Output is correct
14 Correct 116 ms 290236 KB Output is correct
15 Correct 132 ms 290292 KB Output is correct
16 Correct 124 ms 290244 KB Output is correct
17 Correct 134 ms 290256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 290196 KB Output is correct
2 Correct 122 ms 290152 KB Output is correct
3 Correct 139 ms 290216 KB Output is correct
4 Correct 114 ms 290296 KB Output is correct
5 Correct 121 ms 290244 KB Output is correct
6 Correct 114 ms 290204 KB Output is correct
7 Correct 119 ms 290176 KB Output is correct
8 Correct 137 ms 290156 KB Output is correct
9 Correct 134 ms 290236 KB Output is correct
10 Correct 133 ms 290160 KB Output is correct
11 Correct 124 ms 290240 KB Output is correct
12 Correct 117 ms 290212 KB Output is correct
13 Correct 135 ms 290196 KB Output is correct
14 Correct 116 ms 290236 KB Output is correct
15 Correct 132 ms 290292 KB Output is correct
16 Correct 124 ms 290244 KB Output is correct
17 Correct 134 ms 290256 KB Output is correct
18 Correct 120 ms 290216 KB Output is correct
19 Correct 129 ms 290248 KB Output is correct
20 Correct 123 ms 290236 KB Output is correct
21 Correct 136 ms 290268 KB Output is correct
22 Correct 111 ms 290204 KB Output is correct
23 Correct 121 ms 290252 KB Output is correct
24 Correct 127 ms 290232 KB Output is correct
25 Correct 193 ms 290192 KB Output is correct
26 Correct 117 ms 290268 KB Output is correct
27 Correct 141 ms 290208 KB Output is correct
28 Correct 113 ms 290244 KB Output is correct
29 Correct 123 ms 290264 KB Output is correct
30 Correct 128 ms 290244 KB Output is correct
31 Correct 134 ms 290260 KB Output is correct
32 Correct 124 ms 290240 KB Output is correct
33 Correct 122 ms 290248 KB Output is correct
34 Correct 113 ms 290224 KB Output is correct
35 Correct 116 ms 290188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 290196 KB Output is correct
2 Correct 122 ms 290152 KB Output is correct
3 Correct 139 ms 290216 KB Output is correct
4 Correct 114 ms 290296 KB Output is correct
5 Correct 121 ms 290244 KB Output is correct
6 Correct 114 ms 290204 KB Output is correct
7 Correct 119 ms 290176 KB Output is correct
8 Correct 137 ms 290156 KB Output is correct
9 Correct 134 ms 290236 KB Output is correct
10 Correct 133 ms 290160 KB Output is correct
11 Correct 124 ms 290240 KB Output is correct
12 Correct 117 ms 290212 KB Output is correct
13 Correct 135 ms 290196 KB Output is correct
14 Correct 116 ms 290236 KB Output is correct
15 Correct 132 ms 290292 KB Output is correct
16 Correct 124 ms 290244 KB Output is correct
17 Correct 134 ms 290256 KB Output is correct
18 Incorrect 1026 ms 290268 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 290196 KB Output is correct
2 Correct 122 ms 290152 KB Output is correct
3 Correct 139 ms 290216 KB Output is correct
4 Correct 114 ms 290296 KB Output is correct
5 Correct 121 ms 290244 KB Output is correct
6 Correct 114 ms 290204 KB Output is correct
7 Correct 119 ms 290176 KB Output is correct
8 Correct 137 ms 290156 KB Output is correct
9 Correct 134 ms 290236 KB Output is correct
10 Correct 133 ms 290160 KB Output is correct
11 Correct 124 ms 290240 KB Output is correct
12 Correct 117 ms 290212 KB Output is correct
13 Correct 135 ms 290196 KB Output is correct
14 Correct 116 ms 290236 KB Output is correct
15 Correct 132 ms 290292 KB Output is correct
16 Correct 124 ms 290244 KB Output is correct
17 Correct 134 ms 290256 KB Output is correct
18 Correct 120 ms 290216 KB Output is correct
19 Correct 129 ms 290248 KB Output is correct
20 Correct 123 ms 290236 KB Output is correct
21 Correct 136 ms 290268 KB Output is correct
22 Correct 111 ms 290204 KB Output is correct
23 Correct 121 ms 290252 KB Output is correct
24 Correct 127 ms 290232 KB Output is correct
25 Correct 193 ms 290192 KB Output is correct
26 Correct 117 ms 290268 KB Output is correct
27 Correct 141 ms 290208 KB Output is correct
28 Correct 113 ms 290244 KB Output is correct
29 Correct 123 ms 290264 KB Output is correct
30 Correct 128 ms 290244 KB Output is correct
31 Correct 134 ms 290260 KB Output is correct
32 Correct 124 ms 290240 KB Output is correct
33 Correct 122 ms 290248 KB Output is correct
34 Correct 113 ms 290224 KB Output is correct
35 Correct 116 ms 290188 KB Output is correct
36 Incorrect 1026 ms 290268 KB Output isn't correct
37 Halted 0 ms 0 KB -