This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "tickets.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
long long find_maximum(int k, vector<vector<int>> a) {
int n = a.size();
int m = a[0].size();
vector<vector<int>> answer(n, vector<int>(m, -1));
vector<int> l(n), r(n);
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
l[i] += (a[i][j] == 0);
}
r[i] = m;
}
long long ret = 0;
for(int t = 0; t < k; t++) {
vector<int> v(n);
iota(all(v), 0);
sort(all(v), [&](int x, int y) {
return l[x] > l[y];
});
int pos = n;
for(int j = 0; j < n; j++) {
int i = v[j];
if(l[i] == 0) {
pos = i;
break;
} if(i >= n / 2 && r[i] - l[i] > 0) {
pos = i;
break;
}
}
ret += min(pos, n - pos);
for(int i = 0; i < pos; i++) {
int id = v[i];
answer[id][--l[id]] = t;
}
for(int i = pos; i < n; i++) {
int id = v[i];
answer[id][--r[id]] = t;
}
}
allocate_tickets(answer);
return ret;
}
# | 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... |