답안 #201581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201581 2020-02-11T08:36:04 Z theStaticMind Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
5 ms 380 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 = 0; cnt <= n; cnt++){

                        int cwT1 = INF, cwT2 = INF, ccwT1 = INF, ccwT2 = INF, cwT, ccwT;
                        if(cnt > 0){
                              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]);
                              cwT = min(cwT1, cwT2);
                              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 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Incorrect 5 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Incorrect 5 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Incorrect 5 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Incorrect 5 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -