제출 #771727

#제출 시각아이디문제언어결과실행 시간메모리
771727khshg카니발 티켓 (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); vector<vector<int>> qs(k); vector<int> L(N, 0), R(N, M - 1); for(int i = 0; i < k; ++i) { vector<bool> is(N); int sum = 0; for(int j = 0; j < N && sum < N / 2; ++j) { if(x[j][L[j]] == 0) { is[j] = 1; ++sum; } } for(int j = 0; j < N; ++j) { if(is[j]) { ans[j][L[j]] = i; qs[i].push_back(x[j][L[j]]); ++L[j]; } else { ans[j][R[j]] = i; qs[i].push_back(x[j][R[j]]); --R[j]; } } } 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...