| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1306575 | witek_cpp | 카니발 티켓 (IOI20_tickets) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define f(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) f(i, 0, a)
#define tv(a, x) for (auto& a : x)
#define DUZO 1000000000000000000LL
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
/*void allocate_tickets(vvi ans) {
int n = sz(ans);
int m = sz(ans[0]);
cout << "moja odpowiedz to:\n";
rep(i, n) {
rep(j, m) {
cout << ans[i][j] << " ";
}
cout << "\n";
}
}*/
ll find_maximum(int k, vvi x) {
int n = sz(x);
int m = sz(x[0]);
vvi ans(n, vi(m));
int wnk = 0;
rep(i, n) {
rep(j, m) ans[i][j] = -1;
}
vi wsk_r(n, m - 1);
vi wsk_l(n, 0);
rep(_, k) {
vector<pii> p1(n);
rep(i, n) {
p1[i] = {x[i][wsk_l[i]] + x[i][wsk_r[i]], i};
}
sort(all(p1));
vi uzyte;
rep(i, (n/2)) {
int ind = p1[i].nd;
ans[ind][wsk_l[ind]] = _;
uzyte.pb(x[ind][wsk_l[ind]]);
wsk_l[ind]++;
}
f(i, (n/2), n) {
int ind = p1[i].nd;
ans[ind][wsk_r[ind]] = _;
uzyte.pb(x[ind][wsk_r[ind]]);
wsk_r[ind]++;
}
sort(all(uzyte));
int med = (uzyte[n/2] + uzyte[(n/2) - 1])/2;
tv(x, uzyte) wnk += abs(med - x);
}
allocate_tickets(ans);
return wnk;
}
/*int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int k = 2;
//[[0, 2, 5],[1, 1, 3]]
vvi x = {{0, 2, 5}, {1, 1, 3}};
}*/
