Submission #771667

#TimeUsernameProblemLanguageResultExecution timeMemory
771667khshgCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms212 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<int>> ans(N, vector<int>(M, -1)); vector<int> sum(N); for(int i = 0; i < N; ++i) { for(auto& u : x[i]) { sum[i] += u; } } vector<int> ind(N); iota(begin(ind), end(ind), 0); sort(begin(ind), end(ind), [&](const int& i, const int& j) { return sum[i] < sum[j]; }); vector<vector<int>> qs(k); for(int i = 0; i < k; ++i) { for(int j = 0; j < N / 2; ++j) { ans[ind[j]][i] = i; qs[i].push_back(x[ind[j]][i]); } for(int j = N / 2; j < N; ++j) { ans[ind[j]][N - i - 1] = i; qs[i].push_back(x[ind[j]][N - i - 1]); } } allocate_tickets(ans); long long D = 0; for(auto& u : qs) { for(auto& v : u) { D += abs(v - u[N / 2]); } } return D; }
#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...