답안 #922622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922622 2024-02-05T20:21:18 Z LucaLucaM 메기 농장 (IOI22_fish) C++17
3 / 100
1000 ms 2097152 KB
#ifndef FISH_CPP_INCLUDED
#define FISH_CPP_INCLUDED

#include "fish.h"

#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>

typedef long long ll;

bool sub1(std::vector<int> v) {
  for (const auto &x : v) {
    if (x & 1) {
      return false;
    }
  }
  return true;
}

long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y,
                      std::vector<int> w) {
  if (sub1(x)) {
    ll s = 0;
    for (const auto &v : w) {
      s += v;
    }
    return s;
  }
  n++;
  ll cnt[n + 1][n + 1];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < m; i++) {
    x[i]++, y[i]++;
    x[i] = n - 1 - x[i] + 1;
    cnt[x[i]][y[i]] += w[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cnt[i][j] += cnt[i - 1][j];
    }
  }
  ll dp[n + 1][n + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= (i == n? 0 : n); j++) {
      for (int k = 0; k <= (i == 2? 0 : n); k++) {
        dp[i][j] = std::max(dp[i][j], dp[i - 2][k] + cnt[i - 1][std::max(j, k)]);
      }
    }
  }
  return dp[n][0];
  return 0;
}


#endif // FISH_CPP_INCLUDED
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2648 KB Output is correct
2 Correct 22 ms 4800 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 71 ms 14932 KB Output is correct
6 Correct 72 ms 15212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 1037 ms 2097152 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 1037 ms 2097152 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2648 KB Output is correct
2 Correct 22 ms 4800 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 71 ms 14932 KB Output is correct
6 Correct 72 ms 15212 KB Output is correct
7 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -