제출 #771686

#제출 시각아이디문제언어결과실행 시간메모리
771686khshg카니발 티켓 (IOI20_tickets)C++14
11 / 100
1 ms724 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<long long> 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]][M - i - 1] = i; qs[i].push_back(x[ind[j]][M - i - 1]); } } allocate_tickets(ans); long long D = 0; for(auto& u : qs) { sort(begin(u), end(u)); 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...