답안 #627740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627740 2022-08-12T20:52:23 Z Abrar_Al_Samit Collecting Stamps 3 (JOI20_ho_t3) C++17
25 / 100
2000 ms 257624 KB
#include<bits/stdc++.h>
using namespace std;

const int MX = 203;

int n, L;
int pos[MX], T[MX];
map<tuple<int,int,int>, int>dp;
int MAXT;

int dist(int i, int j) {
  int ret = abs(pos[i]-pos[j]);
  return min(ret, L-ret);
}
int solve(int i, int j, int CLOCK) {
  if(CLOCK>MAXT) return 0;
  if(dp.count({i, j, CLOCK})) return dp[{i, j, CLOCK}];
  int ret = 0;
  if(i<j) {
    if(i<n) ret = solve(j, i+1, CLOCK+dist(i, j));
    else ret = solve(j, j, CLOCK+dist(i, j));

    if(i<n) ret = max(ret, solve(i+1, j, CLOCK+dist(i, i+1)));    
  } else if(i>j) {
    if(i>1) ret = solve(j, i-1, CLOCK+dist(j, i));
    else ret = solve(j, j, CLOCK+dist(j, i));
    if(i>1) ret = max(ret, solve(i-1, j, CLOCK+dist(i, i-1)));
  }
  ret += CLOCK<=T[i];
  dp[{i, j, CLOCK}] = ret;
  return ret;
}
void PlayGround() {
  cin>>n>>L;
  for(int i=1; i<=n; ++i) {
    cin>>pos[i];
  }
  for(int i=1; i<=n; ++i) {
    cin>>T[i];
    MAXT = max(MAXT, T[i]);
  }
  cout << max(solve(1, n, pos[1]), solve(n, 1, L-pos[n])) << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 21 ms 3356 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 9 ms 1748 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 419 ms 39440 KB Output is correct
19 Correct 311 ms 29428 KB Output is correct
20 Correct 101 ms 12804 KB Output is correct
21 Correct 246 ms 25292 KB Output is correct
22 Correct 261 ms 26640 KB Output is correct
23 Correct 219 ms 20824 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 204 ms 20100 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 217 ms 20440 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 211 ms 20684 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 239 ms 19948 KB Output is correct
32 Correct 4 ms 1076 KB Output is correct
33 Correct 189 ms 19424 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 157 ms 15968 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 182 ms 17836 KB Output is correct
38 Correct 32 ms 4044 KB Output is correct
39 Correct 209 ms 20844 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 400 ms 39784 KB Output is correct
42 Correct 12 ms 2152 KB Output is correct
43 Correct 391 ms 39108 KB Output is correct
44 Correct 15 ms 2516 KB Output is correct
45 Correct 408 ms 39840 KB Output is correct
46 Correct 12 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 21 ms 3356 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 9 ms 1748 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 419 ms 39440 KB Output is correct
37 Correct 311 ms 29428 KB Output is correct
38 Correct 101 ms 12804 KB Output is correct
39 Correct 246 ms 25292 KB Output is correct
40 Correct 261 ms 26640 KB Output is correct
41 Correct 219 ms 20824 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 204 ms 20100 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 217 ms 20440 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 211 ms 20684 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 239 ms 19948 KB Output is correct
50 Correct 4 ms 1076 KB Output is correct
51 Correct 189 ms 19424 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 157 ms 15968 KB Output is correct
54 Correct 0 ms 340 KB Output is correct
55 Correct 182 ms 17836 KB Output is correct
56 Correct 32 ms 4044 KB Output is correct
57 Correct 209 ms 20844 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 400 ms 39784 KB Output is correct
60 Correct 12 ms 2152 KB Output is correct
61 Correct 391 ms 39108 KB Output is correct
62 Correct 15 ms 2516 KB Output is correct
63 Correct 408 ms 39840 KB Output is correct
64 Correct 12 ms 2388 KB Output is correct
65 Execution timed out 2096 ms 257624 KB Time limit exceeded
66 Halted 0 ms 0 KB -