이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll calculate_score(vector<int> A){
int N = A.size();
ll sum = 0;
int mid = A[N/2];
for(int i = 0; i < N; i++){
sum += abs(A[i] - mid);
}
return sum;
}
ll find_maximum(int k, vector<vector<int>> X){
ll ans = 0;
int N = X.size();
int M = X[0].size();
vector<int> s(M, -1);
vector<vector<int>> S(N, s);
vector<int> large;
vector<int> small;
vector<int> A;
for(int i = 0; i < k; i++){
large.clear();
small.clear();
A.clear();
for(int j = 0; j < N; j++){
large.push_back(X[j][(M - 1) - i]);
small.push_back(X[j][0 + i]);
S[j][(M - 1) - i] = i;
S[j][0 + i] = i;
}
sort(large.begin(), large.end());
sort(small.begin(), small.end());
for(int j = 0; j < N/2; j++){
A.push_back(small[j]);
}
for(int j = N/2; j < N; j++){
A.push_back(large[j]);
}
ans += calculate_score(A);
}
allocate_tickets(S);
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... |