답안 #1072489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072489 2024-08-23T20:09:23 Z Boas 메기 농장 (IOI22_fish) C++17
23 / 100
1000 ms 2097152 KB
#include "fish.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;

#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
#define int long long
#define INF ((int64_t)(4e18 + 1))
#define INF32 ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define F first
#define S second
#define var const auto &
#define foreach(l) for (var e : l)

typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<i32> vi32;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int max_weights(i32 N, i32 M, vi32 X, vi32 Y, vi32 W)
{
  if (M == 0)
    return 0;
  int yCount = *max_element(ALL(Y)) + 2;
  vvi wsAtX(N, vi(yCount));
  vvi wSum(N, vi(yCount));
  loop(M, i)
  {
    wsAtX[X[i]][Y[i]] = W[i];
  }
  loop(N, x)
  {
    loop1(yCount - 1, y)
    {
      wSum[x][y] = wSum[x][y - 1] + wsAtX[x][y - 1];
    }
  }
  vvvvi dp(N, vvvi(yCount, vvi(yCount, vi(2)))); // 0: adjacentL, 1: adjacentR
  vi maxAll(N);
  vvi maxOfHeight(N, vi(yCount));
  loop(N, x)
  {
    vvi pMax1perJ(yCount, vi(yCount)); // dp[x - 1][<=j][i][1]
    if (x != 0)
    {
      loop(yCount, j)
      {
        loop(yCount, i)
        {
          pMax1perJ[j][i] = max(j == 0 ? 0 : pMax1perJ[j - 1][i], dp[x - 1][j][i][1]);
        }
      }
    }
    loop(yCount, j)
    {
      int prevMax = 0;
      if (x != 0)
      {
        loop(yCount, i)
        {
          prevMax = max(prevMax, dp[x - 1][j][i][0]);
        }
      }
      loop(yCount, i) // hoogte van deze steiger
      {
        if (j <= i)
        {
          dp[x][i][j][0] = dp[x][i][j][1] = (x == 0) ? 0 : maxOfHeight[x - 1][i];
        }
        else
        {
          int sum = wSum[x][j] - wSum[x][i];
          if (x == 0)
          {
            dp[x][i][j][0] = -1;
            dp[x][i][j][1] = sum;
          }
          else
          {
            dp[x][i][j][0] = max(dp[x - 1][j][i][1], prevMax) + sum;
            dp[x][i][j][1] = max(pMax1perJ[j][i], maxAll[x - 1]) + sum;
          }
        }
        maxAll[x] = max({maxAll[x], dp[x][i][j][0]});
        maxOfHeight[x][j] = max({maxOfHeight[x][j], dp[x][i][j][0], dp[x][i][j][1]});
      }
    }
  }
  return maxAll.back();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 854 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 866 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 51280 KB Output is correct
2 Correct 66 ms 51056 KB Output is correct
3 Correct 74 ms 48212 KB Output is correct
4 Correct 72 ms 52564 KB Output is correct
5 Correct 90 ms 55216 KB Output is correct
6 Correct 80 ms 54424 KB Output is correct
7 Correct 83 ms 55120 KB Output is correct
8 Correct 81 ms 55124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 3 ms 1884 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 3 ms 1884 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 1372 KB Output is correct
15 Execution timed out 1125 ms 1489696 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 3 ms 1884 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 1372 KB Output is correct
15 Execution timed out 1125 ms 1489696 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 51280 KB Output is correct
2 Correct 66 ms 51056 KB Output is correct
3 Correct 74 ms 48212 KB Output is correct
4 Correct 72 ms 52564 KB Output is correct
5 Correct 90 ms 55216 KB Output is correct
6 Correct 80 ms 54424 KB Output is correct
7 Correct 83 ms 55120 KB Output is correct
8 Correct 81 ms 55124 KB Output is correct
9 Runtime error 855 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 854 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -