Submission #657951

#TimeUsernameProblemLanguageResultExecution timeMemory
657951mychecksedadCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define all(x) x.begin(), x.end() void allocate_tickets(vector<vector<int>> _x); long long find_maximum(int k, vector<vector<int>> _arr) { int N = _arr.size(), M = _arr[0].size(); vector<vector<int>> answer; for (int i = 0; i < N; i++) { std::vector<int> row(M, -1); answer.push_back(row); } vector<vector<int>> unused(N), small(N); ll ans = 0; for(int i = 0; i < N; ++i){ for(int j = 0; j < k; ++j) small[i].pb(_arr[i][j]); for(int j = k; j < M; ++j) unused[i].pb(_arr[i][j]); } for(int i = 0; i < k; ++i){ priority_queue<pair<int, int>> q; for(int j = 0; j < N; ++j) q.push({unused[j].back() + small[i].back(), i}); for(int j = 0; j < N; ++j){ int v = q.top().second; q.pop(); if(j < N/2){ ans += unused[v].back(); answer[v][k - 1 + unused.size()] = i; }else{ ans -= small[v].back(); answer[v][small.size() - 1] = i; } unused[v].pop_back(); small[v].pop_back(); } } allocate_tickets(answer); 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...