# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
713257 | t6twotwo | Catfish Farm (IOI22_fish) | C++17 | 1079 ms | 20148 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int64_t>> solve(vector<vector<int>> &pos, vector<vector<array<int, 2>>> &w) {
int N = pos.size() - 1;
vector<vector<int64_t>> dp(N + 1);
dp[0].push_back(0);
for (int i = 1; i <= N; i++) {
int M = pos[i].size();
dp[i].resize(M);
for (int j = 0; j < M; j++) {
for (int k = 0; k < pos[i - 1].size() && pos[i - 1][k] <= pos[i][j]; k++) {
int64_t add = 0;
for (int l = 0; l < w[i - 1].size(); l++) {
if (w[i - 1][l][0] > pos[i - 1][k] && w[i - 1][l][0] <= pos[i][j]) {
add += w[i - 1][l][1];
}
}
dp[i][j] = max(dp[i][j], dp[i - 1][k] + add);
}
}
}
return dp;
}
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
vector<vector<array<int, 2>>> w(N + 1);
for (int i = 0; i < M; i++) {
w[X[i] + 1].push_back({Y[i], W[i]});
}
vector pos(N + 1, vector<int>{-1});
for (int i = 1; i <= N; i++) {
sort(w[i].begin(), w[i].end());
for (auto [x, _] : w[i]) {
if (i > 1) pos[i - 1].push_back(x);
if (i < N) pos[i + 1].push_back(x);
}
}
for (int i = 1; i <= N; i++) {
sort(pos[i].begin(), pos[i].end());
}
auto dp1 = solve(pos, w);
reverse(pos.begin() + 1, pos.end());
reverse(w.begin() + 1, w.end());
auto dp2 = solve(pos, w);
int64_t ans = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < pos[i + 1].size(); j++) {
ans = max(ans, dp1[N - i][j] + dp2[i + 1][j]);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |