Submission #432115

#TimeUsernameProblemLanguageResultExecution timeMemory
432115peuchCarnival Tickets (IOI20_tickets)C++17
27 / 100
3054 ms105872 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int> > x) { int n = x.size(); int m = x[0].size(); vector<vector<pair<long long, int> > > ord (n, vector<pair<long long, int> > (m)); vector<deque<pair<int, int> > > pilha (n); vector<vector<int> > ans (n, vector<int> (m, -1)); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++) ord[i][j] = make_pair(x[i][j], j); sort(ord[i].begin(), ord[i].end()); for(int j = 0; j < m; j++) pilha[i].push_back(ord[i][j]); } long long sum = 0; for(int c = 0; c < k; c++){ vector<long long> dp (n); vector<vector<bool> > bt (n, vector<bool> (n, 0)); for(int i = 0; i < n; i++){ for(int j = n / 2; j >= 0; j--){ dp[j] = dp[j] - pilha[i].front().first; if(j != 0 && dp[j - 1] + pilha[i].back().first > dp[j]) dp[j] = dp[j - 1] + pilha[i].back().first, bt[i][j] = 1; } } int curI = n - 1, curJ = n / 2; while(curI >= 0){ if(bt[curI][curJ]) curJ--, ans[curI][pilha[curI].back().second] = c, pilha[curI].pop_back(); else ans[curI][pilha[curI].front().second] = c, pilha[curI].pop_front(); curI--; } sum += dp[n / 2]; } allocate_tickets(ans); return sum; }
#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...