답안 #224798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224798 2020-04-18T20:47:37 Z Haunted_Cpp Visiting Singapore (NOI20_visitingsingapore) C++17
10 / 100
243 ms 568 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 = -1e9;
  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 i = 0; i < n + 1; i++) {
    //mn = max ({mn, dp[i][m][0][0], dp[i][m][0][1], dp[i][m][1][1], dp[i][m][1][0]});
  }
  cout << mn << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 19 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 8 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 12 ms 512 KB Output is correct
10 Correct 20 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 8 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 12 ms 512 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 16 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 21 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 512 KB Output is correct
2 Correct 16 ms 512 KB Output is correct
3 Correct 103 ms 568 KB Output is correct
4 Correct 243 ms 512 KB Output is correct
5 Incorrect 76 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 512 KB Output is correct
2 Correct 16 ms 512 KB Output is correct
3 Correct 103 ms 568 KB Output is correct
4 Correct 243 ms 512 KB Output is correct
5 Incorrect 76 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 512 KB Output is correct
2 Correct 16 ms 512 KB Output is correct
3 Correct 103 ms 568 KB Output is correct
4 Correct 243 ms 512 KB Output is correct
5 Incorrect 76 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 19 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 8 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 12 ms 512 KB Output is correct
10 Correct 20 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 12 ms 512 KB Output is correct
17 Correct 12 ms 512 KB Output is correct
18 Correct 16 ms 512 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 21 ms 512 KB Output is correct
21 Correct 33 ms 512 KB Output is correct
22 Correct 16 ms 512 KB Output is correct
23 Correct 103 ms 568 KB Output is correct
24 Correct 243 ms 512 KB Output is correct
25 Incorrect 76 ms 512 KB Output isn't correct
26 Halted 0 ms 0 KB -