Submission #901690

#TimeUsernameProblemLanguageResultExecution timeMemory
901690iliccmarkoCatfish Farm (IOI22_fish)C++17
12 / 100
78 ms13668 KiB
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define ll long long #define endl "\n" #define INF 1000000000 #define LINF 10000000000000000LL #define pb push_back #define all(x) x.begin(), x.end() #define len(s) (int)s.size() #define test_case { int t; cin>>t; while(t--)solve(); } #define single_case solve(); #define line cerr<<"----------"<<endl; #define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); } #define mod 1000000007LL long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { vector<ll> val(n, 0); for (int i = 0; i < m; ++i) { val[x[i]] += (ll)w[i]; } vector<vector<ll> > dp(n, vector<ll>(3, 0)); for (int i = 0; i < n; ++i) { if (i - 1 >= 0) { dp[i][0] = max({dp[i - 1][2], dp[i - 1][1], dp[i - 1][0]}); if (i + 1 < n) dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]); } if (i - 2 >= 0) { dp[i][1] = max({dp[i - 2][1] , dp[i - 2][2], dp[i - 2][0]}); } if (i - 1 >= 0) dp[i][1] += (ll)val[i]; if (i + 1 < n) dp[i][2] += (ll)val[i]; } return max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}); }
#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...