Submission #1130644

#TimeUsernameProblemLanguageResultExecution timeMemory
1130644vibeduckCatfish Farm (IOI22_fish)C++20
0 / 100
23 ms2748 KiB
#include "fish.h" #include <vector> #include <bits/stdc++.h> using namespace std; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { if (N == 2) { int ans[2]; for (int i = 0; i < M; i++) ans[X[i]] += W[i]; return max(ans[0], ans[1]); } vector<int> h[2]; for (int i = 0; i < M; i++) h[X[i]].push_back(Y[i]); std::sort(h[0].begin(), h[0].end()); std::sort(h[1].begin(), h[1].end()); long long ans = accumulate(h[1].begin(), h[1].end(), 0); long long cur = 0; int ptr = 0; for (int i = 0; i < h[0].size(); i++) { cur += h[0][i]; while (ptr < h[1].size()) { if (h[1][ptr] > h[0][i]) break; cur -= h[1][ptr]; ptr++; } ans = max(ans, ans + cur); } 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...