이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <iostream>
#include <algorithm>
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>> answer;
for (int i = 0; i < n; i++) {
vector<int> row(m);
for (int j = 0; j < m; j++) {
if (j < k) {
row[j] = j;
} else {
row[j] = -1;
}
}
answer.push_back(row);
}
vector<long long> l;
long long sum = 0;
for (int i = 0; i < n; i++)
{
l.push_back(x[i][0]);
sum+=x[i][0];
for (int j = 0; j < m; j++)
answer[i][j] = 0;
}
sort(l.begin(), l.end());
long long int md = l[n/2 -1], md1 = l[n/2 -1];
long long ans, ans1 = 0, ans2 = 0;
for(int i = 0; i<n; i++)
{
ans1 += max(l[i]-md, md-l[i]);
ans2 += max(l[i]-md1, md1-l[i]);
}
ans = min(ans1, ans2);
allocate_tickets(answer);
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... |