답안 #224799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224799 2020-04-18T20:51:32 Z Haunted_Cpp Visiting Singapore (NOI20_visitingsingapore) C++17
23 / 100
281 ms 640 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]]);
          }
        }
      }  
      for (int x = 0; x < 2; x++) {
        // 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);
      }
      for (int x = 0; x < 2; x++) {
        // 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 = 0; j < m; j++) {
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
          cur[j][x][y] = nxt[j][x][y];
          mn = max (mn, cur[m][x][y]);
          mn = max (mn, nxt[m][x][y]);
        }   
      }
    }
    for (int j = 0; j < N; j++) {
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {          
          nxt[j][0][0] = -1e9;
          nxt[j][0][1] = -1e9;
          nxt[j][1][0] = -1e9;
          nxt[j][1][1] = -1e9;
        }
      }
    }
    cur[0][0][0] = 0;
    nxt[0][0][0] = 0;
  }
  cout << mn << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 25 ms 512 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 12 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 15 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 9 ms 512 KB Output is correct
9 Correct 19 ms 512 KB Output is correct
10 Correct 28 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 11 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 17 ms 512 KB Output is correct
7 Correct 17 ms 512 KB Output is correct
8 Correct 22 ms 512 KB Output is correct
9 Correct 8 ms 512 KB Output is correct
10 Correct 28 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 512 KB Output is correct
2 Correct 37 ms 512 KB Output is correct
3 Correct 136 ms 512 KB Output is correct
4 Correct 281 ms 512 KB Output is correct
5 Incorrect 88 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 512 KB Output is correct
2 Correct 37 ms 512 KB Output is correct
3 Correct 136 ms 512 KB Output is correct
4 Correct 281 ms 512 KB Output is correct
5 Incorrect 88 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 512 KB Output is correct
2 Correct 37 ms 512 KB Output is correct
3 Correct 136 ms 512 KB Output is correct
4 Correct 281 ms 512 KB Output is correct
5 Incorrect 88 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 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 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 6 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 6 ms 640 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 25 ms 512 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 12 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 15 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 9 ms 512 KB Output is correct
9 Correct 19 ms 512 KB Output is correct
10 Correct 28 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 11 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 17 ms 512 KB Output is correct
17 Correct 17 ms 512 KB Output is correct
18 Correct 22 ms 512 KB Output is correct
19 Correct 8 ms 512 KB Output is correct
20 Correct 28 ms 512 KB Output is correct
21 Correct 62 ms 512 KB Output is correct
22 Correct 37 ms 512 KB Output is correct
23 Correct 136 ms 512 KB Output is correct
24 Correct 281 ms 512 KB Output is correct
25 Incorrect 88 ms 512 KB Output isn't correct
26 Halted 0 ms 0 KB -