# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580043 | slime | 카니발 티켓 (IOI20_tickets) | C++14 | 2 ms | 724 KiB |
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 "bits/stdc++.h"
#include "tickets.h"
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> d);
void allocate_tickets( std::vector<std::vector<int>> _x);
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>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
row[j] = -1;
}
answer.push_back(row);
}
vector<pair<int, int> > v;
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
v.push_back({x[i][j], i});
}
}
sort(v.begin(), v.end());
int cnt[n];
for(int i=0; i<n; i++) cnt[i] = 0;
int distinct = 0;
long long s = 0;
for(int i=0; i<v.size(); i++) {
cnt[v[i].second]++;
if(cnt[v[i].second] == 1) distinct++;
if(distinct == n/2) {
int b = v[i].first;
int sad[n];
for(int j = v.size()-1; j >= 0; j--) {
if(cnt[v[j].second] == 0) {
cnt[v[j].second] = -1;
s += v[j].first - b;
sad[v[j].second] = v[j].first;
}
}
for(int j=0; j<=i; j++) {
if(cnt[v[j].second] > 0) {
cnt[v[j].second] = -1;
s += b - v[j].first;
sad[v[j].second] = v[j].first;
}
}
for(int j=0; j<n; j++) {
for(int l=0; l<m; l++) {
if(x[j][l] == sad[j]) {
answer[j][l] = 0; break;
}
}
}
break;
}
}
allocate_tickets(answer);
return s;
}
//13210230
Compilation message (stderr)
# | 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... |