Submission #1073355

#TimeUsernameProblemLanguageResultExecution timeMemory
1073355ZicrusCatfish Farm (IOI22_fish)C++17
6 / 100
59 ms19028 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; typedef long long ll; int n, m; vector<int> x, y, w; ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { n = N; m = M; x = X; y = Y; w = W; if (n == 2) { ll sumA = 0, sumB = 0; for (int i = 0; i < m; i++) { if (x[i] > 0) sumB += w[i]; else sumA += w[i]; } return max(sumA, sumB); } ll res = 0; for (int i = 0; i < m; i++) { if (x[i] > 0) res += w[i]; } ll mx = res; vector<ll> a(n), b(n); for (int i = 0; i < m; i++) { if (x[i] > 0) b[y[i]] = w[i]; else a[y[i]] = w[i]; } for (int i = 0; i < n; i++) { res -= b[i]; res += a[i]; mx = max(mx, res); } return mx; } #ifdef TEST #include "grader.cpp" #endif
#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...