제출 #771366

#제출 시각아이디문제언어결과실행 시간메모리
771366PurpleCrayon메기 농장 (IOI22_fish)C++17
0 / 100
1085 ms18112 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; #define sz(v) int(v.size()) #define ar array typedef long long ll; const int N = 1e5+10, MOD = 1e9+7; vector<pair<int, int>> fish[N]; vector<int> use[N]; ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { for (int i = 0; i < n; i++) { fish[x[i]].emplace_back(y[i], w[i]); if (x[i]) use[x[i]-1].push_back(y[i]); if (x[i] < n-1) use[x[i]+1].push_back(y[i]); } for (int i = 0; i < n; i++) { use[i].push_back(-1); sort(use[i].begin(), use[i].end()); sort(fish[i].begin(), fish[i].end()); } vector<ll> prv_l{0}, prv_r{0}; vector<int> prv_h{-1}; vector<pair<int, int>> prv_fish; for (int c = 0; c < n; c++) { int k = sz(use[c]); vector<ll> cur_l(k), cur_r(k); auto cur_h = use[c]; auto cur_fish = fish[c]; for (int i = 0; i < sz(prv_h); i++) { for (int j = 0; j < sz(cur_h); j++) { ll cost_prv = prv_r[j]; for (auto f : prv_fish) if (prv_h[i] < f.first && f.first <= cur_h[i]) cost_prv += f.second; cost_prv = max(cost_prv, prv_l[j]); cur_r[j] = max(cur_r[j], cost_prv); for (auto f : cur_fish) if (cur_h[i] < f.first && f.first <= prv_h[i]) cost_prv += f.second; cur_r[j] = max(cur_r[j], cost_prv); } } swap(prv_l, cur_l); swap(prv_r, cur_r); swap(prv_h, cur_h); swap(prv_fish, cur_fish); } ll ans = 0; for (ll x : prv_l) ans = max(ans, x); for (ll x : prv_r) ans = max(ans, x); 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...