# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106953 | 2024-10-31T09:58:37 Z | I_am_Polish_Girl | Catfish Farm (IOI22_fish) | C++17 | 59 ms | 26292 KB |
/* 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 <vector <int>> dp0(n); vector <vector <int>> dp1(n); for (int i = 0; i < n; i++) { dp0[i].resize(vp[i].size()); dp1[i].resize(vp[i].size()); } int ans = 0; int mx_ = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < vp[i].size(); j++) { ans = max(ans , mx_ + vp[i][j].second); } if (i != n - 1) { int ind = 0; int sz = vp[i].size(); int mx = 0; for (int j = 0; j < sz; j++) { while ((ind < vp[i - 1].size()) and (vp[i - 1][ind] < vp[i][j])) { mx = max(mx, dp0[i - 1][ind]); ind++; } mx = max(mx, mx_); dp0[i][j] = mx + vp[i][j].second; mx = max(mx, dp0[i][j]); } } if (i != 0) { int ind = vp[i - 1].size(); ind--; int sz = vp[i].size(); int mx = 0; for (int j = sz - 1; j >= 0; j--) { while ((ind >= 0) and (vp[i - 1][ind] > vp[i][j])) { mx = max(mx, dp1[i - 1][ind]); ind--; } mx = max(mx, mx_); dp1[i][j] = mx + vp[i][j].second; mx = max(mx, dp1[i][j]); } } for (int j = 0; j < vp[i].size(); j++) { ans = max(ans, dp0[i][j]); ans = max(ans, dp1[i][j]); } if (i - 1 >= 0) { for (int j = 0; j < vp[i - 1].size(); j++) { mx_ = max(mx_, dp0[i - 1][j]); mx_ = max(mx_, dp1[i - 1][j]); } } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 38 ms | 19740 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Runtime error | 59 ms | 26292 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 14672 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 336 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 336 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 336 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 14672 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 38 ms | 19740 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |