답안 #625708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625708 2022-08-10T17:22:25 Z d4xn 메기 농장 (IOI22_fish) C++17
0 / 100
157 ms 43396 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>

const int N = 1e5+5, inf = INT_MAX;

int n, m;
int c[8][N];
bitset<N> vis[10][10];
ll dp[10][10][N]; // dp[i][j][k] = maximos peces que puedo conseguir
              // con las k primeras columnas donde
              // en la columna k+1 he subido i-1
              // en la columna k+2 he subido j-1

ll mx(int curr, int h1, int h2) {
  if (curr == -1) return 0;
  
  if (vis[h1][h2][curr]) return dp[h1][h2][curr];
  
  dp[h1][h2][curr] = 0;
  vis[h1][h2][curr] = 1;

  for (int h = 0; h < min(10, n+1); h++) {
    ll cnt = 0;

    // ver si pillo los de la derecha
    if (curr+1 < n) {
      for (int i = 0; i < h; i++) {
        if (h2-1 < i && h1-1 < i) cnt += c[i][curr+1];
      }
    }

    // ver si pillo los de la izquierda
    if (curr-1 >= 0) {
      for (int i = 0; i < h; i++) {
        cnt += c[i][curr-1];
      }
    }

    // ver si he eliminado alguno de los que he pillado
    for (int i = 0; i < min(h, h1); i++) {
      cnt -= c[i][curr];
    }

    dp[h1][h2][curr] = max(dp[h1][h2][curr], cnt + mx(curr-1, h, h1));
  }
  return dp[h1][h2][curr];
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
  
  for (int i = 0; i < 8; i++) {
    memset(c[i], 0, sizeof(c[i]));
  }

  n = N;
  m = M;
  for (int i = 0; i < m; i++) {
    c[Y[i]][X[i]] = W[i];
  }
  return mx(n-1, 0, 0);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 11252 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3540 KB Output is correct
2 Runtime error 62 ms 15340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 157 ms 43396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3668 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3432 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Incorrect 6 ms 4436 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '216909958864'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3668 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3432 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Incorrect 6 ms 4436 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '216909958864'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3668 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3432 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Incorrect 6 ms 4436 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '216909958864'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 157 ms 43396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 11252 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -