Submission #224797

# Submission time Handle Problem Language Result Execution time Memory
224797 2020-04-18T20:42:54 Z Haunted_Cpp Visiting Singapore (NOI20_visitingsingapore) C++17
23 / 100
277 ms 764 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 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;
    
  }
  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;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 26 ms 512 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 11 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 14 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 10 ms 512 KB Output is correct
9 Correct 19 ms 512 KB Output is correct
10 Correct 31 ms 764 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 11 ms 596 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 24 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 28 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 512 KB Output is correct
2 Correct 40 ms 512 KB Output is correct
3 Correct 138 ms 512 KB Output is correct
4 Correct 277 ms 640 KB Output is correct
5 Incorrect 87 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 512 KB Output is correct
2 Correct 40 ms 512 KB Output is correct
3 Correct 138 ms 512 KB Output is correct
4 Correct 277 ms 640 KB Output is correct
5 Incorrect 87 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 512 KB Output is correct
2 Correct 40 ms 512 KB Output is correct
3 Correct 138 ms 512 KB Output is correct
4 Correct 277 ms 640 KB Output is correct
5 Incorrect 87 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 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 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 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 6 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 26 ms 512 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 11 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 14 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 10 ms 512 KB Output is correct
9 Correct 19 ms 512 KB Output is correct
10 Correct 31 ms 764 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 596 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 24 ms 512 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 28 ms 512 KB Output is correct
21 Correct 56 ms 512 KB Output is correct
22 Correct 40 ms 512 KB Output is correct
23 Correct 138 ms 512 KB Output is correct
24 Correct 277 ms 640 KB Output is correct
25 Incorrect 87 ms 512 KB Output isn't correct
26 Halted 0 ms 0 KB -