Submission #1054470

#TimeUsernameProblemLanguageResultExecution timeMemory
1054470ProtonDecay314Catfish Farm (IOI22_fish)C++17
0 / 100
45 ms12132 KiB
#include "fish.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef vector<vpi> vvpi; typedef vector<vpll> vvpll; typedef vector<bool> vb; typedef vector<vb> vvb; typedef short int si; typedef vector<si> vsi; typedef vector<vsi> vvsi; #define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++) #define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--) #define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++) #define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--) #define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci #define fi first #define se second #define pb push_back #define INF(type) numeric_limits<type>::max() #define NINF(type) numeric_limits<type>::min() #define TCASES int t; cin >> t; while(t--) ll max_weights(int N, int M, vi X, vi Y, vi W) { ll ans = 0ll; ll sum0 = 0ll; ll sum1 = 0ll; for(ll i = 0ll; i < M; i++) { (X[i] == 0 ? sum0 : sum1) += (ll)W[i]; } if(N == 2) { ans = max(sum0, sum1); } else { vll pref_0(M + 1ll, 0ll); vll suff_1(M + 1ll, 0ll); L(i, 0ll, M) { pref_0[i + 1ll] = pref_0[i] + (X[i] == 0 ? W[i] : 0ll); } LR(i, M, -1ll) { suff_1[i] = suff_1[i + 1ll] + (X[i] == 1 ? W[i] : 0ll); } L(i, 0ll, M + 1ll) { ans = max(ans, pref_0[i] + suff_1[i]); } } 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...