Submission #628257

# Submission time Handle Problem Language Result Execution time Memory
628257 2022-08-13T09:01:21 Z abeker Catfish Farm (IOI22_fish) C++17
0 / 100
937 ms 2097152 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;

typedef long long ll;

const ll INF = 1e18;

ll max_weights(int N, int M, vector <int> x, vector <int> y, vector <int> w) {
  vector <vector <ll>> mat(N + 2, vector <ll> (N));
  for (int i = 0; i < M; i++)
    mat[x[i] + 1][y[i]] = w[i];
  vector <ll> sum(N + 2);
  vector <ll> maks(N + 2), mini(N + 2);
  for (int i = 1; i < N + 2; i++) {
    ll curr = 0;
    for (int j = 0; j < N; j++) {
      sum[i] += mat[i][j];
      curr += mat[i - 1][j] - mat[i][j];
      maks[i] = max(maks[i], curr);
      mini[i] = max(mini[i], -curr);
    }
  }
  auto make_sum = [&](vector <ll> &v) {
    for (int i = 1; i < v.size(); i++)
      v[i] += v[i - 1];
  };
  make_sum(maks);
  make_sum(mini);
  auto get_sum = [&](const vector <ll> &pref, int lo, int hi) {
    return pref[hi] - (lo ? pref[lo - 1] : 0);
  };
  vector <vector <ll>> trans(N + 2, vector <ll> (N + 2, -INF));
  for (int i = 0; i < N + 2; i++)
    for (int j = i + 2; j < N + 2; j++)
      for (int k = i + 1; k < j; k++)
        trans[i][j] = max(trans[i][j], get_sum(maks, i + 1, k - 1) + get_sum(mini, k + 2, j) + sum[k - 1] + sum[k + 1]);
  vector <ll> dp(N + 2, -INF);
  for (int i = 0; i < N + 2; i++)
    for (int j = i - 2; j >= 0; j--)
      dp[i] = max(dp[i], (j ? dp[j - 1] : 0) + trans[j][i]);
  return dp[N + 1];
}

Compilation message

fish.cpp: In lambda function:
fish.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 1; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 937 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 790 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 785 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Incorrect 2 ms 596 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '215227631108'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Incorrect 2 ms 596 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '215227631108'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Incorrect 2 ms 596 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '215227631108'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 785 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 937 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -