이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
bool ok = true;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(x[i][j] > 1){
ok = false;
}
}
}
vector<vector<int>> answer(n, vector<int>(m,-1));
ll result = 0;
if(m == 1){
vector<vector<int>> answer(n, vector<int>(m,0));
vector<int>v;
for(int i = 0; i < n; i++) v.pb(x[i][0]);
sort(v.begin(),v.end());
ll result = 0;
for(int i = 0; i < n; i++) result += abs(v[i]-v[n/2]);
allocate_tickets(answer);
return result;
}
if(ok){
/*vector< pair<vector<int>,int> > v(n);
for(int i = 0; i < n; i++){
v[i] = {x[i],i};
}*/
sort(x.begin(),x.end());
vector<int>a(m,0);
vector<pair<int,int>>p;
for(int j = 0; j < m; j++){
int sum = 0;
for(int i = 0; i < n; i++){
sum += x[i][j];
}
a[j] = min(sum,n-sum);
p.pb({a[j],j});
}
sort(p.rbegin(), p.rend());
//int l = 0, r = m-1;
for(int i = 0; i < k; i++){
int l = p[i].ss;
result += p[i].ff;
for(int j = 0; j < n; j++){
answer[j][l] = i;
}
}
allocate_tickets(answer);
return result;
}
allocate_tickets(answer);
return result;
}
# | 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... |