이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
struct el {
long long x, y, idx;
bool operator < (const el &oth) const {
return make_pair(x, y) < make_pair(oth.x, oth.y);
}
};
// bool comp (pair <long, long> a, pair <long, long> b) {
// if (a.first != b.first) return a.first <
// }
long long find_maximum(int k, vector<vector<int>> x) {
long long n = x.size();
long long m = x[0].size();
if (m == 1){ // subtask 1
vector<vector<int>> answer (n, vector <int> (m));
long long rs = 0;
vector <int> v;
for (int i = 0; i < n; i++){
v.push_back(x[i][0]);
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++){
rs+=abs(x[i][0] - v[n / 2]);
}
allocate_tickets(answer);
return rs;
}
else if (k == 1) { // subtask 2
vector<vector<int>> answer (n, vector <int> (m, -1));
long long rs = 0;
vector <el > v;
for (int i = 0; i < n; i++){
v.push_back({x[i][0], x[i][m-1], i});
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++){
if (i < n / 2) {
rs-=v[i].x;
answer[v[i].idx][0] = 0;
}
else {
rs+=v[i].y;
answer[v[i].idx][m-1] = 0;
}
}
allocate_tickets(answer);
return rs;
}
else { // subtask 3
}
return -1;
}
# | 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... |