이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long find_maximum(signed k, vector<vector<signed>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<signed>> answer(n, vector<signed>(m));
// vector<pair<int,int>> v;
// for(int i = 0; i < n; i++) {
// v.push_back({x[i], i});
// }
// sort(v.begin(), v.end());
// for(int i = 0; i < n)
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (j < k) {
answer[i][j] = j;
} else {
answer[i][j] = -1;
}
}
}
allocate_tickets(answer);
vector<vector<int>> rounds(k);
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
if(answer[i][j] != -1)
rounds[answer[i][j]].push_back(x[i][j]);
int ans = 0;
for(int i = 0; i < k; i++) {
if(rounds[i].empty()) continue;
int idx = rounds[i].size()/2;
if(rounds[i].size()%2)
for(auto x: rounds[i])
ans += abs(x - rounds[i][idx]);
else
for(auto x: rounds[i])
ans += abs(x - (rounds[i][idx]+rounds[i][idx-1])/2);
}
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... |