답안 #201579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201579 2020-02-11T08:07:34 Z theStaticMind Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
5 ms 376 KB
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
//      freopen("q.gir","r",stdin);
//      freopen("q.cik","w",stdout);
      int n, L, ans = 0;
      cin >> n >> L;
      vector<int> X(n + 1),T(n + 1);
      X[0] = 0;
      T[0] = 0;
      for(int i = 1; i <= n; i++)cin >> X[i];
      for(int i = 1; i <= n; i++)cin >> T[i];
      X.pb(L);
      T.pb(0);
      int dp[n + 1][n + 2][n + 1][2];
      for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n + 1; j++){
                  for(int k = 0; k <= n; k++){
                        if(k == 0 && i == 0 && j == n + 1)dp[i][j][k][0] = dp[i][j][k][1] = 0;
                        else dp[i][j][k][0] = dp[i][j][k][1] = INF;
                  }
            }
      }
      for(int cw = 0; cw <= n; cw++){
            for(int ccw = n + 1; ccw >= cw; ccw--){
                  for(int cnt = 1; cnt <= n; cnt++){
                        int cwT1 = INF, cwT2 = INF, ccwT1 = INF, ccwT2 = INF;
                        if(cw != 0)cwT1 = dp[cw - 1][ccw][cnt - 1][1] + (X[cw] - X[cw - 1]);
                        if(cw != 0)cwT2 = dp[cw - 1][ccw][cnt - 1][0] + (L - X[ccw] + X[cw]);
                        if(ccw != n + 1)ccwT1 = dp[cw][ccw + 1][cnt - 1][1] + (X[cw] + L - X[ccw]);
                        if(ccw != n + 1)ccwT2 = dp[cw][ccw + 1][cnt - 1][0] + (X[ccw + 1] - X[ccw]);
                        int cwT = min(cwT1, cwT2);
                        int ccwT =  min(ccwT1, ccwT2);
                        if(T[cw] >= cwT) dp[cw][ccw][cnt][1] = cwT;
                        if(T[ccw] >= ccwT) dp[cw][ccw][cnt][0] = ccwT;
                    
                    
                        cwT1 = INF, cwT2 = INF, ccwT1 = INF, ccwT2 = INF;
                        if(cw != 0)cwT1 = dp[cw - 1][ccw][cnt][1] + (X[cw] - X[cw - 1]);
                        if(cw != 0)cwT2 = dp[cw - 1][ccw][cnt][0] + (L - X[ccw] + X[cw]);
                        if(ccw != n + 1)ccwT1  = dp[cw][ccw + 1][cnt][1] + (X[cw] + L - X[ccw]);
                        if(ccw != n + 1)ccwT2  = dp[cw][ccw + 1][cnt][0] + (X[ccw + 1] - X[ccw]);
                        cwT = min(cwT1, cwT2);
                        ccwT =  min(ccwT1, ccwT2);
                        dp[cw][ccw][cnt][1] = min(dp[cw][ccw][cnt][1], cwT);
                        dp[cw][ccw][cnt][0] = min(dp[cw][ccw][cnt][0], ccwT);
                  }
            }
      }
      for(int i = 0; i <= n; i++){
            for(int j = n + 1; j >= i; j--){
                  for(int k = 0; k <= n; k++){
                        for(int q = 0; q < 2; q++){

                              if(dp[i][j][k][q] < 1e15) ans = max(ans, k);
                        }

                  }
            }
      }
      cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -