Submission #224804

# Submission time Handle Problem Language Result Execution time Memory
224804 2020-04-18T21:15:27 Z Haunted_Cpp Visiting Singapore (NOI20_visitingsingapore) C++17
100 / 100
701 ms 760 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
 
typedef long long i64;
using namespace std;

const int N = 5e3 + 5;

int cur [N][2][2];
int nxt [N][2][2];

int k, n, m, a, b;

int felicidade_evento [N];
int dia_evento [N];
int tarefas [N];

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> k >> n >> m >> a >> b;
  for (int i = 1; i <= k; i++) cin >> felicidade_evento[i];
  for (int i = 0; i < n; i++) cin >> dia_evento[i];
  for (int i = 0; i < m; i++) cin >> tarefas[i];
  for (int j = 0; j < N; j++) {
    nxt[j][0][0] = cur[j][0][0] = -1e9;
    nxt[j][0][1] = cur[j][0][1] = -1e9;
    nxt[j][1][0] = cur[j][1][0] = -1e9;
    nxt[j][1][1] = cur[j][1][1] = -1e9;
  }
  cur[0][0][0] = nxt[0][0][0] = 0;
  // Day / Task / Jump Task / Jump day
  int mn = a + (m * b);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < m; j++) {  
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) { 
          if (tarefas[j] == dia_evento[i]) {
            nxt[j + 1][0][0] = max (nxt[j + 1][0][0], cur[j][x][y] + felicidade_evento[tarefas[j]]);
          }
          // Start to jump task
          cur[j + 1][1][x] = max (cur[j + 1][1][x], cur[j][0][x] + a + b);
          // Continue to jump task
          cur[j + 1][1][x] = max (cur[j + 1][1][x], cur[j][1][x] + b);
          // Start to jump day
          nxt[j][x][1] = max (nxt[j][x][1], cur[j][x][0] + a + b);
          // Continue to jump day
          nxt[j][x][1] = max (nxt[j][x][1], cur[j][x][1] + b);
          
        }
      }  
    } 
    for (int j = 1; j < m; j++) {
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
          mn = max (mn, nxt[m][x][y]);
          cur[j][x][y] = nxt[j][x][y];
          nxt[j][x][y] = -1e9;
          mn = max (mn, cur[m][x][y]);
        }   
      }
    }
  }
  cout << mn << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 27 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 12 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 18 ms 512 KB Output is correct
10 Correct 32 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 12 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 7 ms 512 KB Output is correct
6 Correct 18 ms 564 KB Output is correct
7 Correct 18 ms 512 KB Output is correct
8 Correct 24 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 33 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 512 KB Output is correct
2 Correct 29 ms 512 KB Output is correct
3 Correct 216 ms 512 KB Output is correct
4 Correct 507 ms 632 KB Output is correct
5 Correct 153 ms 512 KB Output is correct
6 Correct 225 ms 632 KB Output is correct
7 Correct 405 ms 512 KB Output is correct
8 Correct 132 ms 512 KB Output is correct
9 Correct 260 ms 512 KB Output is correct
10 Correct 631 ms 640 KB Output is correct
11 Correct 621 ms 632 KB Output is correct
12 Correct 627 ms 512 KB Output is correct
13 Correct 613 ms 512 KB Output is correct
14 Correct 700 ms 632 KB Output is correct
15 Correct 678 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 512 KB Output is correct
2 Correct 29 ms 512 KB Output is correct
3 Correct 216 ms 512 KB Output is correct
4 Correct 507 ms 632 KB Output is correct
5 Correct 153 ms 512 KB Output is correct
6 Correct 225 ms 632 KB Output is correct
7 Correct 405 ms 512 KB Output is correct
8 Correct 132 ms 512 KB Output is correct
9 Correct 260 ms 512 KB Output is correct
10 Correct 631 ms 640 KB Output is correct
11 Correct 621 ms 632 KB Output is correct
12 Correct 627 ms 512 KB Output is correct
13 Correct 613 ms 512 KB Output is correct
14 Correct 700 ms 632 KB Output is correct
15 Correct 678 ms 632 KB Output is correct
16 Correct 326 ms 632 KB Output is correct
17 Correct 402 ms 612 KB Output is correct
18 Correct 363 ms 632 KB Output is correct
19 Correct 78 ms 512 KB Output is correct
20 Correct 242 ms 512 KB Output is correct
21 Correct 21 ms 512 KB Output is correct
22 Correct 84 ms 512 KB Output is correct
23 Correct 161 ms 632 KB Output is correct
24 Correct 59 ms 512 KB Output is correct
25 Correct 614 ms 624 KB Output is correct
26 Correct 624 ms 624 KB Output is correct
27 Correct 631 ms 512 KB Output is correct
28 Correct 618 ms 636 KB Output is correct
29 Correct 676 ms 632 KB Output is correct
30 Correct 677 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 512 KB Output is correct
2 Correct 29 ms 512 KB Output is correct
3 Correct 216 ms 512 KB Output is correct
4 Correct 507 ms 632 KB Output is correct
5 Correct 153 ms 512 KB Output is correct
6 Correct 225 ms 632 KB Output is correct
7 Correct 405 ms 512 KB Output is correct
8 Correct 132 ms 512 KB Output is correct
9 Correct 260 ms 512 KB Output is correct
10 Correct 631 ms 640 KB Output is correct
11 Correct 621 ms 632 KB Output is correct
12 Correct 627 ms 512 KB Output is correct
13 Correct 613 ms 512 KB Output is correct
14 Correct 700 ms 632 KB Output is correct
15 Correct 678 ms 632 KB Output is correct
16 Correct 520 ms 632 KB Output is correct
17 Correct 243 ms 632 KB Output is correct
18 Correct 77 ms 512 KB Output is correct
19 Correct 22 ms 640 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 18 ms 512 KB Output is correct
22 Correct 241 ms 760 KB Output is correct
23 Correct 47 ms 512 KB Output is correct
24 Correct 424 ms 512 KB Output is correct
25 Correct 596 ms 632 KB Output is correct
26 Correct 635 ms 632 KB Output is correct
27 Correct 604 ms 640 KB Output is correct
28 Correct 604 ms 604 KB Output is correct
29 Correct 679 ms 600 KB Output is correct
30 Correct 669 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 640 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 27 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 12 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 18 ms 512 KB Output is correct
10 Correct 32 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 12 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 7 ms 512 KB Output is correct
16 Correct 18 ms 564 KB Output is correct
17 Correct 18 ms 512 KB Output is correct
18 Correct 24 ms 512 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 33 ms 512 KB Output is correct
21 Correct 68 ms 512 KB Output is correct
22 Correct 29 ms 512 KB Output is correct
23 Correct 216 ms 512 KB Output is correct
24 Correct 507 ms 632 KB Output is correct
25 Correct 153 ms 512 KB Output is correct
26 Correct 225 ms 632 KB Output is correct
27 Correct 405 ms 512 KB Output is correct
28 Correct 132 ms 512 KB Output is correct
29 Correct 260 ms 512 KB Output is correct
30 Correct 631 ms 640 KB Output is correct
31 Correct 621 ms 632 KB Output is correct
32 Correct 627 ms 512 KB Output is correct
33 Correct 613 ms 512 KB Output is correct
34 Correct 700 ms 632 KB Output is correct
35 Correct 678 ms 632 KB Output is correct
36 Correct 326 ms 632 KB Output is correct
37 Correct 402 ms 612 KB Output is correct
38 Correct 363 ms 632 KB Output is correct
39 Correct 78 ms 512 KB Output is correct
40 Correct 242 ms 512 KB Output is correct
41 Correct 21 ms 512 KB Output is correct
42 Correct 84 ms 512 KB Output is correct
43 Correct 161 ms 632 KB Output is correct
44 Correct 59 ms 512 KB Output is correct
45 Correct 614 ms 624 KB Output is correct
46 Correct 624 ms 624 KB Output is correct
47 Correct 631 ms 512 KB Output is correct
48 Correct 618 ms 636 KB Output is correct
49 Correct 676 ms 632 KB Output is correct
50 Correct 677 ms 512 KB Output is correct
51 Correct 520 ms 632 KB Output is correct
52 Correct 243 ms 632 KB Output is correct
53 Correct 77 ms 512 KB Output is correct
54 Correct 22 ms 640 KB Output is correct
55 Correct 13 ms 512 KB Output is correct
56 Correct 18 ms 512 KB Output is correct
57 Correct 241 ms 760 KB Output is correct
58 Correct 47 ms 512 KB Output is correct
59 Correct 424 ms 512 KB Output is correct
60 Correct 596 ms 632 KB Output is correct
61 Correct 635 ms 632 KB Output is correct
62 Correct 604 ms 640 KB Output is correct
63 Correct 604 ms 604 KB Output is correct
64 Correct 679 ms 600 KB Output is correct
65 Correct 669 ms 632 KB Output is correct
66 Correct 5 ms 512 KB Output is correct
67 Correct 5 ms 512 KB Output is correct
68 Correct 4 ms 512 KB Output is correct
69 Correct 5 ms 512 KB Output is correct
70 Correct 5 ms 512 KB Output is correct
71 Correct 5 ms 512 KB Output is correct
72 Correct 5 ms 512 KB Output is correct
73 Correct 5 ms 512 KB Output is correct
74 Correct 5 ms 512 KB Output is correct
75 Correct 5 ms 512 KB Output is correct
76 Correct 5 ms 640 KB Output is correct
77 Correct 5 ms 512 KB Output is correct
78 Correct 5 ms 512 KB Output is correct
79 Correct 5 ms 512 KB Output is correct
80 Correct 5 ms 512 KB Output is correct
81 Correct 504 ms 620 KB Output is correct
82 Correct 119 ms 632 KB Output is correct
83 Correct 220 ms 612 KB Output is correct
84 Correct 121 ms 512 KB Output is correct
85 Correct 191 ms 632 KB Output is correct
86 Correct 175 ms 512 KB Output is correct
87 Correct 32 ms 512 KB Output is correct
88 Correct 23 ms 512 KB Output is correct
89 Correct 73 ms 512 KB Output is correct
90 Correct 643 ms 596 KB Output is correct
91 Correct 615 ms 760 KB Output is correct
92 Correct 610 ms 612 KB Output is correct
93 Correct 606 ms 632 KB Output is correct
94 Correct 623 ms 760 KB Output is correct
95 Correct 625 ms 632 KB Output is correct
96 Correct 605 ms 632 KB Output is correct
97 Correct 615 ms 736 KB Output is correct
98 Correct 701 ms 632 KB Output is correct
99 Correct 680 ms 632 KB Output is correct
100 Correct 677 ms 512 KB Output is correct