답안 #568183

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568183 2022-05-24T19:32:50 Z Ronin13 Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
73 ms 127436 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

const int inf = 1e9 + 1;
const ll linf = 1e18 + 1;

ll dp[201][201][201][2];

int main(){
    ll n, l;
    cin >> n >> l;
    ll a[n + 2];
    ll t[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> t[i];
    }
    for(int i = 0; i <= 200; i++){
        for(int j = 0; j <= 200; j++){
            for(int k = 0; k <= 200; k++) dp[i][j][k][0] = dp[i][j][k][1] = linf;
        }
    }
    dp[0][0][0][0] = 0;
    dp[0][0][0][1] = 0;
    a[0] = 0;
    a[n + 1] = l;
    // 0 marcxniv 1 marjvniv
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i + j > n) continue;
            for(int x = 0; x < n; x++){
                ll nt = dp[i][j][x][0] + l - a[n - i + 1] + a[j + 1];
                nt = min(nt, dp[i][j][x][1] + a[j + 1] - a[j]);
                if(nt <= t[j + 1]) dp[i][j + 1][x + 1][1] = min(dp[i][j + 1][x + 1][1], nt);
                else dp[i][j + 1][x][1] = min(dp[i][j + 1][x][1], nt);
                nt = dp[i][j][x][0] + a[n - i + 1] - a[n - i];
                nt = min(nt, dp[i][j][x][1] + l - a[n - i] + a[j]);
                if(nt <= t[n - i]) dp[i + 1][j][x + 1][0] = min(dp[i + 1][j][x + 1][0], nt);
                else dp[i + 1][j][x][0] = min(dp[i + 1][j][x][0], nt);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int x = 1; x <= n; x++) {
            if(dp[i][n - i][x][0] != linf) ans = max(x, ans);
            if(dp[i][n - i][x][1] != linf) ans = max(x, ans);
        }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 127340 KB Output is correct
2 Correct 54 ms 127404 KB Output is correct
3 Correct 56 ms 127364 KB Output is correct
4 Correct 55 ms 127328 KB Output is correct
5 Correct 60 ms 127348 KB Output is correct
6 Correct 63 ms 127300 KB Output is correct
7 Correct 56 ms 127364 KB Output is correct
8 Correct 54 ms 127388 KB Output is correct
9 Correct 53 ms 127308 KB Output is correct
10 Correct 54 ms 127328 KB Output is correct
11 Correct 55 ms 127332 KB Output is correct
12 Correct 65 ms 127364 KB Output is correct
13 Correct 56 ms 127436 KB Output is correct
14 Correct 53 ms 127312 KB Output is correct
15 Correct 53 ms 127320 KB Output is correct
16 Correct 56 ms 127400 KB Output is correct
17 Correct 55 ms 127396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 127340 KB Output is correct
2 Correct 54 ms 127404 KB Output is correct
3 Correct 56 ms 127364 KB Output is correct
4 Correct 55 ms 127328 KB Output is correct
5 Correct 60 ms 127348 KB Output is correct
6 Correct 63 ms 127300 KB Output is correct
7 Correct 56 ms 127364 KB Output is correct
8 Correct 54 ms 127388 KB Output is correct
9 Correct 53 ms 127308 KB Output is correct
10 Correct 54 ms 127328 KB Output is correct
11 Correct 55 ms 127332 KB Output is correct
12 Correct 65 ms 127364 KB Output is correct
13 Correct 56 ms 127436 KB Output is correct
14 Correct 53 ms 127312 KB Output is correct
15 Correct 53 ms 127320 KB Output is correct
16 Correct 56 ms 127400 KB Output is correct
17 Correct 55 ms 127396 KB Output is correct
18 Correct 57 ms 127412 KB Output is correct
19 Correct 54 ms 127412 KB Output is correct
20 Correct 60 ms 127412 KB Output is correct
21 Correct 58 ms 127308 KB Output is correct
22 Correct 54 ms 127316 KB Output is correct
23 Correct 60 ms 127308 KB Output is correct
24 Correct 53 ms 127380 KB Output is correct
25 Correct 56 ms 127396 KB Output is correct
26 Correct 56 ms 127304 KB Output is correct
27 Correct 57 ms 127312 KB Output is correct
28 Correct 53 ms 127308 KB Output is correct
29 Correct 52 ms 127400 KB Output is correct
30 Correct 53 ms 127392 KB Output is correct
31 Correct 54 ms 127412 KB Output is correct
32 Correct 57 ms 127416 KB Output is correct
33 Correct 64 ms 127308 KB Output is correct
34 Correct 57 ms 127368 KB Output is correct
35 Correct 52 ms 127308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 127340 KB Output is correct
2 Correct 54 ms 127404 KB Output is correct
3 Correct 56 ms 127364 KB Output is correct
4 Correct 55 ms 127328 KB Output is correct
5 Correct 60 ms 127348 KB Output is correct
6 Correct 63 ms 127300 KB Output is correct
7 Correct 56 ms 127364 KB Output is correct
8 Correct 54 ms 127388 KB Output is correct
9 Correct 53 ms 127308 KB Output is correct
10 Correct 54 ms 127328 KB Output is correct
11 Correct 55 ms 127332 KB Output is correct
12 Correct 65 ms 127364 KB Output is correct
13 Correct 56 ms 127436 KB Output is correct
14 Correct 53 ms 127312 KB Output is correct
15 Correct 53 ms 127320 KB Output is correct
16 Correct 56 ms 127400 KB Output is correct
17 Correct 55 ms 127396 KB Output is correct
18 Correct 65 ms 127404 KB Output is correct
19 Correct 60 ms 127328 KB Output is correct
20 Correct 59 ms 127324 KB Output is correct
21 Correct 73 ms 127408 KB Output is correct
22 Correct 68 ms 127312 KB Output is correct
23 Correct 55 ms 127312 KB Output is correct
24 Incorrect 55 ms 127308 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 127340 KB Output is correct
2 Correct 54 ms 127404 KB Output is correct
3 Correct 56 ms 127364 KB Output is correct
4 Correct 55 ms 127328 KB Output is correct
5 Correct 60 ms 127348 KB Output is correct
6 Correct 63 ms 127300 KB Output is correct
7 Correct 56 ms 127364 KB Output is correct
8 Correct 54 ms 127388 KB Output is correct
9 Correct 53 ms 127308 KB Output is correct
10 Correct 54 ms 127328 KB Output is correct
11 Correct 55 ms 127332 KB Output is correct
12 Correct 65 ms 127364 KB Output is correct
13 Correct 56 ms 127436 KB Output is correct
14 Correct 53 ms 127312 KB Output is correct
15 Correct 53 ms 127320 KB Output is correct
16 Correct 56 ms 127400 KB Output is correct
17 Correct 55 ms 127396 KB Output is correct
18 Correct 57 ms 127412 KB Output is correct
19 Correct 54 ms 127412 KB Output is correct
20 Correct 60 ms 127412 KB Output is correct
21 Correct 58 ms 127308 KB Output is correct
22 Correct 54 ms 127316 KB Output is correct
23 Correct 60 ms 127308 KB Output is correct
24 Correct 53 ms 127380 KB Output is correct
25 Correct 56 ms 127396 KB Output is correct
26 Correct 56 ms 127304 KB Output is correct
27 Correct 57 ms 127312 KB Output is correct
28 Correct 53 ms 127308 KB Output is correct
29 Correct 52 ms 127400 KB Output is correct
30 Correct 53 ms 127392 KB Output is correct
31 Correct 54 ms 127412 KB Output is correct
32 Correct 57 ms 127416 KB Output is correct
33 Correct 64 ms 127308 KB Output is correct
34 Correct 57 ms 127368 KB Output is correct
35 Correct 52 ms 127308 KB Output is correct
36 Correct 65 ms 127404 KB Output is correct
37 Correct 60 ms 127328 KB Output is correct
38 Correct 59 ms 127324 KB Output is correct
39 Correct 73 ms 127408 KB Output is correct
40 Correct 68 ms 127312 KB Output is correct
41 Correct 55 ms 127312 KB Output is correct
42 Incorrect 55 ms 127308 KB Output isn't correct
43 Halted 0 ms 0 KB -