Submission #1245125

#TimeUsernameProblemLanguageResultExecution timeMemory
1245125guanexCatfish Farm (IOI22_fish)C++20
0 / 100
50 ms10564 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) { long long ans = 0; long long an = 0; vector<long long> suff(N+1, 0); vector<long long> pref = suff; vector<long long> preff = suff; vector<long long> suf = suff; for(int i = 0; i < (int)W.size(); ++i){ if(X[i] == 0){ ans += W[i]; pref[i] = W[i]; suff[i] = W[i]; }else{ an += W[i]; preff[i] = W[i]; suf[i] = W[i]; } } long long mx = max(ans, an); if(N == 2){ return mx; } for(int i = 1; i < N; ++i){ pref[i] += pref[i-1]; preff[i] += preff[i-1]; } for(int i = N-2; i >= 0; --i){ suff[i] += suff[i+1]; suf[i] += suf[i+1]; } for(int i = 0; i < N; ++i){ mx = max(mx, pref[i] + suf[i+1]); mx = max(mx, preff[i] + suff[i+1]); } return mx; }
#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...