Submission #1069275

#TimeUsernameProblemLanguageResultExecution timeMemory
1069275beaconmcCatfish Farm (IOI22_fish)C++17
14 / 100
1091 ms112468 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) const ll maxn = 100005; set<ll> fish[maxn]; map<vector<ll>, ll> weights; ll dp[10][10][maxn]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { FOR(i,0,10){ FOR(j,0,10){ FOR(k,0,maxn){ dp[i][j][k] = 0; } } } FOR(i,0,M){ Y[i]++; fish[X[i]].insert(Y[i]); weights[{X[i], Y[i]}] = W[i]; } FOR(k,0,N){ FOR(i,0,10){ FOR(j,0,10){ ll temp = 0; FOR(height, 0, 10){ if (fish[k+1].count(height)) temp += weights[{k+1, height}]; if (fish[k].count(height) && j>=height) temp -= weights[{k, height}]; if (k>0 && fish[k-1].count(height) && i < height && j<height) temp += weights[{k-1, height}]; dp[j][height][k+1] = max(dp[j][height][k+1], dp[i][j][k] + temp); } } } } ll ans = 0; FOR(i,0,10){ FOR(j,0,10){ FOR(k,0,N+1){ ans = max(ans, dp[i][j][k]); //if (dp[i][j][k]==10) cout << i << " " << j << " " << k << endl; } } } 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...