이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define ll long long
#define pll pair<ll, ll>
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x)
{
ll n = x.size();
ll m = x[0].size();
if(m == 1)
{
vector<vector<int>> output(n, vector<int> (1, 0));
allocate_tickets(output);
vector<ll> a(n);
for(ll i = 0; i < n; i++)
{
a[i] = x[i][0];
}
sort(a.begin(), a.end());
ll ans = 0;
ll add = 0;
for(ll i = n/2; i >= 0; i--)
{
add = a[n/2] - a[i];
ans += add;
}
for(ll i = n/2+1; i < n; i++)
{
add = a[i] - a[n/2];
ans += add;
}
return ans;
}
vector<ll> zcount(n, 0);
for(ll i = 0; i < n; i++)
{
for(ll j = 0; j < m; j++)
{
zcount[i] += (x[i][j] == 0);
}
}
vector<pll> zsort(n);
for(ll i = 0; i < n; i++)
{
zsort[i] = {zcount[i], i};
}
sort(zsort.begin(), zsort.end());
vector<bool> big(n, true);
for(ll i = n/2; i < n; i++)
{
big[zsort[i].second] = false;
}
vector<vector<int>> output(n, vector<int> (m, -1));
vector<vector<int>> round(n, vector<int> (k, -1));
for(ll i = 0; i < n; i++)
{
vector<pll> p(m);
for(ll j = 0; j < m; j++)
{
p[j] = {x[i][j], j};
}
sort(p.begin(), p.end());
if(big[i])
{
reverse(p.begin(), p.end());
}
for(ll j = 0; j < k; j++)
{
output[i][p[j].second] = j;
round[i][j] = p[j].first;
}
}
allocate_tickets(output);
ll ans = 0;
for(ll j = 0; j < k; j++)
{
ll counter = 0; //Counts the ones
for(ll i = 0; i < n; i++)
{
counter += round[i][j];
}
ans += min(counter, n-counter);
}
return 0;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |