이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// :)^2
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
const int maxn5 = 2e3 + 10;
pair <ll, int> per[maxn5];
int ptl[maxn5], ptr[maxn5], val[maxn5][maxn5], cnt[maxn5];
vector <int> req[maxn5][2];
vector <pair<int, pair<int, int>>> av;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> ret;
for (int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
av.pb({x[i][j], {i, j}});
ptl[i] = 0;
ptr[i] = m - 1;
vector <int> row(m);
fill(all(row), -1);
ret.push_back(row);
}
sort(all(av));
for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){
int pt = lower_bound(all(av), mp(x[i][j], mp(i, j))) - av.begin();
if(pt < int(av.size()) / 2)
val[i][j] = 0;
else
val[i][j] = 1;
cnt[i] += val[i][j];
}
ll ans = 0;
int num = 0;
while(k--){
for(int i = 0; i < n; i++)
per[i] = {cnt[i], i};
sort(per, per + n);
for(int i = 0; i < n / 2; i++){
int v = per[i].se;
ans -= x[v][ptl[v]];
//cout << "small " << v << ' ' << cnt[v] << ' ' << num << ' ' << ptl[v] << ' ' << x[v][ptl[v]] << ' ' << ans << endl;
ret[v][ptl[v]] = num;
cnt[v] -= val[v][ptl[v]];
ptl[v]++;
}
for(int i = n / 2; i < n; i++){
int v = per[i].se;
ans += x[v][ptr[v]];
//cout << "big " << v << ' ' << cnt[v] << ' ' << num << ' ' << ptr[v] << ' ' << x[v][ptr[v]] << ' ' << ans << endl;
ret[v][ptr[v]] = num;
cnt[v] -= val[v][ptr[v]];
ptr[v]--;
}
num++;
}
allocate_tickets(ret);
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... |