Submission #724092

#TimeUsernameProblemLanguageResultExecution timeMemory
724092ismayilCatfish Farm (IOI22_fish)C++17
0 / 100
26 ms4308 KiB
#pragma GCC optimize("O3") #include "fish.h" #include <bits/stdc++.h> #define ll long long #define endl '\n' using namespace std; const ll INF = 3e14 + 4; ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { ll dp[N][2], a[N]; memset(dp, 0, sizeof(dp)); memset(a, 0, sizeof(a)); for(int i = 0; i < M; i++) a[X[i]] = W[i]; dp[1][0] = max(dp[0][1] + a[1], dp[0][0]); dp[1][1] = max(dp[0][1], dp[0][0] + a[0]); for(int i = 2; i < N; i++){ dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0]); dp[i][1] = max(dp[i - 2][0] + a[i - 1], dp[i - 2][1] + a[i - 1]); } return max(dp[N - 1][0], dp[N - 1][1]); }
#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...