이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include "bits/stdc++.h"
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define le(x) ((x)[((int)(x).size())-1])
#define sz(x) ((int)((x).size()))
#define pb push_back
#define s second
#define f first
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int MxN=1510, INF=1e9;
int n, m, l[MxN], ri[MxN];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
n=sz(x); m=sz(x[0]);
FOR(i, 0, n) ri[i]=m-1;
ll ret=0;
vector s(n, vector(m,-1));
vector<pair<vector<int>,int>> vec;
FOR(i, 0, n) {
vi now;
FOR(j, 0, m) {
now.pb(x[i][j]);
}
vec.pb({now,i});
}
sort(vec.begin(), vec.end());
vi now;
FOR(r, 0, k)
FOR(i, 0, n/2) {
int in1=vec[i].s, in2=vec[n-1-i].s;
int val1=x[in1][l[in1]++], val2=x[in2][ri[in2]--];
s[in1][0]=s[in2][m-1]=r;
now.pb(val1); now.pb(val2);
}
sort(now.begin(), now.end());
int md=now[sz(now)/2];
for(auto it : now) {
ret+=abs(it-md);
}
allocate_tickets(s);
return ret;
}
/*
2 3 2
0 2 5
1 1 3
4 2 1
5 9
1 4
3 6
2 7
4 4 1
0 1 2 9
4 4 4 5
3 3 3 7
3 4 4 4
4 2 1
0 10
1 5
0 6
0 6
4 4 1
0 1 2 9
7 7 7 7
7 7 7 7
7 7 7 7
8 2 1
1 9
0 10
2 3
3 4
6 8
1 5
0 2
3 4
4 3 2
0 1 1
1 1 1
0 0 1
0 0 0
4 2 2
0 1
0 1
0 0
1 1
4 2 1
0 1
0 0
0 0
1 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... |