Submission #393603

# Submission time Handle Problem Language Result Execution time Memory
393603 2021-04-24T05:34:58 Z 79brue Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
1 ms 588 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n; ll l;
ll arr[205], t[205];
ll DP[205][205][205][2]; /// l에 있는 경우 = 0, r에 있는 경우 = 1
int ans;

int main(){
    scanf("%d %lld", &n, &l);
    for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
    for(int i=1; i<=n; i++) scanf("%lld", &t[i]);
    arr[n+1] = l;

    for(int i=0; i<=n+3; i++) for(int j=0; j<=n+3; j++) for(int k=0; k<=n+3; k++) DP[i][j][k][0] = DP[i][j][k][1] = 1e18;
    DP[0][n+1][0][0] = DP[0][n+1][0][1] = 0;

    for(int d=n+1; d>=0; d--){
        for(int i=0; i<=n+1-d; i++){
            int j = i+d;
            for(int p=0; p<=n; p++){
                ll newT; int newP;
                if(DP[i][j][p][0] < 1e18){ /// 현재 i에 있는 경우
                    ans = max(ans, p);
                    if(d){
                        newT = DP[i][j][p][0] + (arr[i+1] - arr[i]);
                        newP = p + (newT <= t[i+1]);
                        DP[i+1][j][newP][0] = min(DP[i+1][j][newP][0], newT);

                        newT = DP[i][j][p][1] + l - (arr[j-1] - arr[i]);
                        newP = p + (newT <= t[j-1]);
                        DP[i][j-1][newP][1] = min(DP[i][j-1][newP][1], newT);
                    }
                }

                if(DP[i][j][p][1] < 1e18){
                    ans = max(ans, p);
                    if(d){
                        newT = DP[i][j][p][1] + l - (arr[j] - arr[i+1]);
                        newP = p + (newT <= t[i+1]);
                        DP[i+1][j][newP][0] = min(DP[i+1][j][newP][0], newT);

                        newT = DP[i][j][p][1] + (arr[j] - arr[j-1]);
                        newP = p + (newT <= t[j-1]);
                        DP[i][j-1][newP][1] = min(DP[i][j-1][newP][1], newT);
                    }
                }
            }
        }
    }

    printf("%d", ans);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d %lld", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
ho_t3.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
ho_t3.cpp:15:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     for(int i=1; i<=n; i++) scanf("%lld", &t[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -