제출 #1130655

#제출 시각아이디문제언어결과실행 시간메모리
1130655vibeduck메기 농장 (IOI22_fish)C++20
6 / 100
210 ms26116 KiB
#include "fish.h" #include <vector> #include <bits/stdc++.h> using namespace std; //#define int long long 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]; ans[0] = 0; ans[1] = 0; for (int i = 0; i < M; i++) ans[X[i]] += W[i]; return max(ans[0], ans[1]); } std::map<std::pair<int, int>, int> v; for (int i = 0; i < M; i++) v[{X[i], Y[i]}] = W[i]; vector<int> h[2]; h[0] = {}; h[1] = {}; 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 og = 0; for (size_t i = 0; i < h[1].size(); i++) og += v[{1, h[1][i]}]; long long cur = 0; long long ans = og; size_t ptr = 0; for (size_t i = 0; i < h[0].size(); i++) { cur += v[{0, h[0][i]}]; while (ptr < h[1].size()) { if (h[1][ptr] > h[0][i]) break; cur -= v[{1, h[1][ptr]}]; ptr++; } ans = max(ans, og + 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...