Submission #626014

#TimeUsernameProblemLanguageResultExecution timeMemory
626014aryan12Catfish Farm (IOI22_fish)C++17
3 / 100
85 ms8812 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; // Subtask 3 bool cmp(array<int, 3> a, array<int, 3> b) { if(a[1] != b[1]) return a[1] < b[1]; return a[0] > b[0]; } long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { vector<long long> vect(N, 0); for(int i = 0; i < M; i++) { vect[X[i]] += W[i]; } if(N == 2) { return max(vect[0], vect[1]); } vector<long long> dp(N, 0); dp[0] = vect[0]; dp[1] = max(dp[0], vect[1]); dp[2] = max(dp[1], dp[0] + vect[2]); long long ans = dp[2]; for(int i = 3; i < N; i++) { dp[i] = max(dp[i - 1], dp[i - 2] + vect[i]); ans = max(ans, dp[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...