답안 #721818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721818 2023-04-11T07:35:37 Z Sharky 메기 농장 (IOI22_fish) C++17
9 / 100
117 ms 13620 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

#define int long long

map<int, int> hv;

int f(int col) {
    if (!hv.count(col)) return 0;
    return hv[col];
}

long long max_weights(int32_t n, int32_t m, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> w) {
    int dp[n + 1][2][2], ans = 0;
    for (int i = 0; i <= n; i++) for (int j = 0; j < 2; j++) for (int k = 0; k < 2; k++) dp[i][j][k] = 0;
    for (int i = 0; i < m; i++) hv[(int) x[i]] = (int) w[i];
    for (int i = 1; i < n; i++) {
        dp[i][0][0] = max({dp[i-1][0][0], dp[i-1][1][0]});
        dp[i][1][0] = max({dp[i-1][1][1] + f(i), dp[i-1][0][1] + f(i)});
        dp[i][0][1] = max(dp[i-1][1][0], dp[i-1][0][0] + f(i-1));
        dp[i][1][1] = max(dp[i-1][1][1], dp[i-1][0][1]);
        ans = max(ans, max({dp[i][0][0], dp[i][0][1] + f(i+1), dp[i][1][1] + f(i+1), dp[i][1][0]}));
    }
    return ans;
}

#ifndef EVAL

int32_t main() {
  int32_t N, M;
  assert(2 == scanf("%d %d", &N, &M));

  std::vector<int32_t> X(M), Y(M), W(M);
  for (int32_t i = 0; i < M; ++i) {
    assert(3 == scanf("%d %d %d", &X[i], &Y[i], &W[i]));
  }

  long long result = max_weights(N, M, X, Y, W);
  printf("%lld\n", result);
  return 0;
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 4956 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3424 KB Output is correct
2 Correct 4 ms 3412 KB Output is correct
3 Correct 65 ms 7588 KB Output is correct
4 Correct 43 ms 7124 KB Output is correct
5 Correct 103 ms 13620 KB Output is correct
6 Correct 99 ms 13000 KB Output is correct
7 Correct 104 ms 13496 KB Output is correct
8 Correct 101 ms 13560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3424 KB Output is correct
2 Correct 4 ms 3412 KB Output is correct
3 Correct 65 ms 7588 KB Output is correct
4 Correct 43 ms 7124 KB Output is correct
5 Correct 103 ms 13620 KB Output is correct
6 Correct 99 ms 13000 KB Output is correct
7 Correct 104 ms 13496 KB Output is correct
8 Correct 101 ms 13560 KB Output is correct
9 Incorrect 117 ms 13260 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 4956 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -