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 <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
typedef pair<int, int> pii;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> ans = vector<vector<int>>(n, vector<int>(m, -1));
set<pii> t[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
t[i].insert({x[i][j], j});
long long win = 0;
for (int r = 0; r < k; r++) {
vector<pii> c;
for (int j = 0; j < n; j++) {
c.push_back({t[j].begin()->first + t[j].rbegin()->first, j});
// cout << c.back().first << ' ';
}
// cout << endl;
sort(c.begin(), c.end());
for (int i = 0; i < n / 2; i++) {
int col = c[i].second;
int ix = t[col].begin()->second;
win -= x[col][ix];
ans[col][ix] = r;
t[col].erase({x[col][ix], ix});
}
for (int i = n / 2; i < n; i++) {
int col = c[i].second;
int ix = t[col].rbegin()->second;
win += x[col][ix];
ans[col][ix] = r;
t[col].erase({x[col][ix], ix});
}
}
allocate_tickets(ans);
return win;
}
# | 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... |