Submission #1256987

#TimeUsernameProblemLanguageResultExecution timeMemory
1256987antonnCarnival Tickets (IOI20_tickets)C++20
0 / 100
0 ms328 KiB
#include "tickets.h" #include <bits/stdc++.h> #define all(a) a.begin(), a.end() using namespace std; typedef long long ll; ll find_maximum(int k, vector<vector<int>> a) { int n = a.size(); int m = a[0].size(); vector<vector<ll>> pref(n + 1, vector<ll>(m + 1)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { pref[i][j] = pref[i][j - 1] + a[i - 1][j - 1]; } } auto smallest = [&](int i, int k) { return pref[i][k]; }; auto biggest = [&](int i, int k) { return pref[i][m] - pref[i][m - k]; }; vector<ll> dp(n * k / 2 + 1, -1e18); dp[0] = 0; for (int i = 1; i <= n; i++) { vector<ll> ndp(n * k / 2 + 1, -1e18); for (int j = 1; j <= n * k / 2; j++) { for (int h = 0; h <= k && h <= j; h++) { ndp[j] = max(ndp[j], dp[j - h] + biggest(i, h) - smallest(i, k - h)); } } swap(dp, ndp); } return dp[n * k / 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...