Submission #1106943

#TimeUsernameProblemLanguageResultExecution timeMemory
1106943I_am_Polish_GirlCatfish Farm (IOI22_fish)C++17
0 / 100
1091 ms10680 KiB
/* In honor of Anton Tsypko I want earrings with minecreaft I want earrings with birbie */ #include "fish.h" #include <vector> #include <algorithm> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <stack> #include <queue> #include <cmath> #include <random> #include <chrono> #include <iomanip> #include <iostream> #include <bitset> #include <cmath> #include <string> using namespace std; int log_ = 23; int inf = 2000000007; int mod = 1000000007; int p = 523; #include <vector> long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { int n = N; vector <vector <pair <int, int>>> vp(n); for (int i = 0; i < X.size(); i++) { vp[X[i]].push_back({ Y[i] , W[i] }); } for (int i = 0; i < n; i++) { sort(vp[i].begin(), vp[i].end()); } vector <int> dp(n); int mx = 0; for (int i = 0; i < n ; i++) { vector <vector <int>> dp_; dp_.resize(n); for (int j = 0; j < n; j++) { dp_[j].resize(vp[j].size()); } int c = mx; for (int j = i; j < n; j++) { int ind = -1; int mx_ = 0; for (int k = 0; k < vp[j].size(); k++) { if (j == i) { mx_ += vp[j][k].second; dp_[j][k] = mx_; dp[i] = max(dp[i], mx_ + c); continue; } while ((ind + 1 != vp[j - 1].size()) and (vp[j - 1][ind + 1].first < vp[j][k].first)) { mx_ = max(mx_, dp_[j - 1][ind + 1]); ind++; } if (mx_ == 0) continue; dp_[j][k] = mx_ + vp[j][k].second; mx_ = max(mx_, dp_[j][k]); if (j != n - 1) dp[j] = max(dp[j], mx_ + c); } if (vp[i].size() == 0) break; } dp_.clear(); dp_.resize(n); for (int j = 0; j < n; j++) { dp_[j].resize(vp[j].size()); } if (i != 0) { for (int j = i; j < n; j++) { int ind = vp[j].size(); int mx_ = 0; int sz = vp[j].size(); for (int k = sz - 1; k >= 0; k--) { dp_[j][k] = 0; if (j == i) { mx_ += vp[j][k].second; dp_[j][k] = mx_; dp[i] = max(dp[i], mx_ + c); continue; } while ((ind - 1 >= 0) and (vp[j - 1][ind - 1].first > vp[j][k].first)) { mx_ = max(mx_, dp_[j - 1][ind - 1]); ind--; } if (mx_ == 0) continue; dp_[j][k] = mx_ + vp[j][k].second; mx_ = max(mx_, dp_[j][k]); if (j != n - 1) dp[j] = max(dp[j], mx_ + c); } if (vp[i].size() == 0) break; } } if (i - 1 >= 0) mx = max(dp[i - 1], mx); } int ans = 0; for (int i = 0; i < n; i++) { ans = max(ans, dp[i]); } return ans; }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for (int i = 0; i < X.size(); i++)
      |                  ~~^~~~~~~~~~
fish.cpp:79:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |    for (int k = 0; k < vp[j].size(); k++)
      |                    ~~^~~~~~~~~~~~~~
fish.cpp:90:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |     while ((ind + 1 != vp[j - 1].size()) and (vp[j - 1][ind + 1].first < vp[j][k].first))
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~
#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...