| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 319279 | northlake | 카니발 티켓 (IOI20_tickets) | C++17 | 1 ms | 384 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, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> s {x};
for (auto& e1 : s) {
for (auto& e2 : e1) e2 = -1;
}
vector<pair<int,int>> min_values;
vector<pair<int,int>> max_values;
for (int i = 0; i < n; i++) {
vector<int> el = x[i];
int minx = pow(10,9);
int maxx = 0;
for (auto e : el) {
minx = min(minx, e);
maxx = max(maxx, e);
}
min_values.push_back(make_pair(minx, i));
max_values.push_back(make_pair(maxx, i));
}
sort(min_values.begin(), min_values.end());
sort(max_values.rbegin(), max_values.rend());
vector<int> values;
bool taken[n] = {false};
for (int i = 0; i < n; i++) {
pair<int,int> small = min_values[i];
pair<int,int> big = max_values[i];
if (taken[small.second] && taken[big.second]) {
continue;
}
else if (taken[small.second]) {
values.push_back(big.first);
taken[big.second] = true;
}
else if (taken[big.second]) {
values.push_back(small.first);
taken[small.second] = true;
}
else if (small.second == big.second) {
values.push_back(small.first);
taken[small.second] = true;
}
else {
values.push_back(small.first);
values.push_back(big.first);
taken[big.second] = true;
taken[small.second] = true;
}
}
sort(values.begin(), values.end());
for (auto val : values) cout << val << " ";
cout << '\n';
int optimal_value = values[n/2];
long long result = 0ll;
for (auto el : x) {
result += static_cast<long long>(abs(optimal_value-el[0]));
}
allocate_tickets(s);
return result;
}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... | ||||
