Submission #1065653

#TimeUsernameProblemLanguageResultExecution timeMemory
1065653j_vdd16Catfish Farm (IOI22_fish)C++17
0 / 100
1066 ms16756 KiB
#include "fish.h" #include <algorithm> #include <bitset> #include <cstdint> #include <cstring> #include <iostream> #include <limits.h> #include <math.h> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define int long long #define loop(X, N) for(int X = 0; X < (N); X++) #define all(V) V.begin(), V.end() #define rall(V) V.rbegin(), V.rend() using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vector<ii>> vvii; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; vvii fishes; int weightSum(int x, int y1, int y2) { if (x >= fishes.size()) return 0; int res = 0; for (auto [y, w] : fishes[x]) { if (y1 <= y && y <= y2) res += w; } return res; } long long max_weights(signed N, signed M, vector<signed> X, std::vector<signed> Y, std::vector<signed> W) { fishes = vvii(N); loop(i, M) { fishes[X[i]].push_back({Y[i], W[i]}); } vector<map<int, int>> dp(N); loop(x, N) { auto& col = fishes[x]; sort(all(col), greater<ii>{}); if (x == 0) { for (auto [y, w] : col) { dp[0][y - 1] = weightSum(1, 0, y - 1); } dp[0][0] = 0; continue; } for (auto [y, w] : fishes[x - 1]) { int bestScore = 0; for (auto [prevY, prevScore] : dp[x - 1]) { int score = prevScore - weightSum(x, 0, min(prevY, y)) + weightSum(x + 1, 0, y) + weightSum(x - 1, prevY + 1, y); bestScore = max(bestScore, score); } dp[x][y] = bestScore; } int bestScore = 0; for (auto [prevY, prevScore] : dp[x - 1]) { int score = prevScore; bestScore = max(bestScore, score); } dp[x][0] = max(dp[x][0], bestScore); } int res = 0; for (auto [y, score] : dp.back()) { res = max(res, score); } return res; }

Compilation message (stderr)

fish.cpp: In function 'long long int weightSum(long long int, long long int, long long int)':
fish.cpp:35:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if (x >= fishes.size())
      |         ~~^~~~~~~~~~~~~~~~
#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...