Submission #1130677

#TimeUsernameProblemLanguageResultExecution timeMemory
1130677vibeduck메기 농장 (IOI22_fish)C++20
0 / 100
1105 ms220848 KiB
#include "fish.h" #include <vector> #include <bits/stdc++.h> using namespace std; //#define int long long //dp[i][j][k] // poisition i, streak of j, building this one to height k void chkmax(long long &a, long long &b) { a = max(a, b); } long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { // n <= 300 const int maxN = 301; long long dp[maxN][3][maxN]; map<pair<int, int>, long long> v; for (int i = 0; i < M; i++) v[{X[i], Y[i]}] = W[i]; long long pfix[maxN][maxN]; for (int i = 0; i < N; i++) { pfix[i][0] = v[{i, 0}]; for (int j = 1; j < N; j++) { pfix[i][j] = pfix[i][j - 1] + v[{i, j}]; } } //for (int i = 0; i < N; i++) { // for (int j = 0; j < N; j++) cout << pfix[i][j] << " "; // cout << '\n'; //} for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) for (int k = 0; k < N; k++) dp[i][j][k] = 0; for (int i = 0; i < N; i++) { dp[0][0][i] = dp[1][0][i] = 0; dp[0][1][i] = pfix[0][i]; dp[1][1][i] = pfix[1][i]; } for (int p = 2; p < N; p++) { for (int hn = 0; hn < N; hn++) { for (int hp = 0; hp < N; hp++) { dp[p][0][hn] = max(dp[p][0][hn], dp[p - 1][0][hp]); dp[p][0][hn] = max(dp[p][0][hn], dp[p - 1][1][hp]); dp[p][0][hn] = max(dp[p][0][hn], dp[p - 1][2][hp]); dp[p][1][hn] = max(dp[p][1][hn], dp[p - 1][0][hp] + pfix[p][hn]); dp[p][1][hn] = max(dp[p][1][hn], dp[p - 2][1][hp] + pfix[p][hn]); dp[p][1][hn] = max(dp[p][1][hn], dp[p - 1][1][hp] + pfix[p][hn] - pfix[p - 1][hp]); if (p != N - 1) { dp[p][2][hn] = max(dp[p][2][hn], dp[p - 1][1][hp] + pfix[p][hn]); } //cout << "pos " << p << " streak 0 height " << hn << ": " << dp[p][0][hn] << '\n'; //cout << "pos " << p << " streak 1 height " << hn << ": " << dp[p][1][hn] << '\n'; //cout << "pos " << p << " streak 2 height " << hn << ": " << dp[p][2][hn] << '\n'; } } } long long ans = 0; for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) for (int k = 0; k < N; k++) ans = max(ans, dp[i][j][k]); return ans; /*long long dp[maxN][3]; vector<long long> a(N, 0); for (int i = 0; i < M; i++) a[X[i]] = W[i]; dp[0][0] = dp[1][0] = 0; dp[0][1] = a[0]; dp[1][1] = a[1]; for (int i = 2; i < N; i++) { dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]}); dp[i][1] = max({dp[i - 1][0] + a[i], dp[i - 1][1] - a[i - 1] + a[i], dp[i - 2][1] + a[i]}); if (i != N - 1) dp[i][2] = max({dp[i - 1][1] + a[i]}); } long long ans = 0; for (int i = 0; i < N; i++) ans = max(ans, max({dp[i][0], dp[i][1], dp[i][2]})); return ans;*/ }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...