Submission #1029107

#TimeUsernameProblemLanguageResultExecution timeMemory
1029107AmadooCarnival Tickets (IOI20_tickets)C++17
27 / 100
315 ms90716 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; const int N = 1505; long long dp[N][N]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); vector <vector <int>> ans(n, vector <int>(m, -1)); for(int i = 1; i <= n; ++i) { for(int j = 0; j <= n; ++j) { if(j == 0) dp[i][j] = dp[i - 1][j] - x[i - 1][0]; else dp[i][j] = max(dp[i - 1][j] - x[i - 1][0], dp[i - 1][j - 1] + x[i - 1][m - 1]); } } for(int i = n, j = (n + 1) / 2; i >= 1; --i) { if(dp[i][j] == dp[i - 1][j] - x[i - 1][0]) { ans[i - 1][0] = 0; } else if(dp[i][j] == dp[i - 1][j - 1] + x[i - 1][m - 1]) { ans[i - 1][m - 1] = 0; j--; } } allocate_tickets(ans); return dp[n][(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...