| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 401221 | my99n | 카니발 티켓 (IOI20_tickets) | C++14 | 2 ms | 716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
vector<vector<int>> answer;
long long findanswer (vector<tuple<int,int,int>> round) {
sort(all(round));
long long med = get<0>(round[round.size()/2]);
long long ans = 0;
for (int i = 0; i < round.size(); i++) {
ans += abs(med-get<0>(round[i]));
}
return ans;
}
int roundcnt = 0;
void setanswer (vector<tuple<int,int,int>> round) {
for (auto x : round) {
int i = get<1>(x);
int j = get<2>(x);
answer[i][j] = roundcnt;
}
roundcnt++;
}
int used[2020];
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
answer = vector<vector<int>>(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
answer[i].push_back(-1);
}
}
vector<tuple<int,int,int>> mn, mx;
for (int i = 0; i < n; i++) {
vector<pair<int,int>> temp;
for (int j = 0; j < m; j++) {
temp.push_back({x[i][j], j});
}
sort(all(temp));
mn.push_back({temp[0].first, i, temp[0].second});
mx.push_back({temp.back().first, i, temp.back().second});
}
sort(all(mn)); sort(all(mx));
vector<tuple<int,int,int>> round1, round2;
for (int i = 0; i <= n/2-1; i++) { // 0-3 when n == 8
used[get<1>(mn[i])] = 1; round1.push_back(mn[i]);
}
int cnt = 0;
for (int i = n-1; i >= 0; i--) {
if (used[get<1>(mx[i])]) continue;
cnt++;
round1.push_back(mx[i]);
if (cnt == n/2) break;
}
memset(used, 0, sizeof used);
for (int i = n-1; i >= 0; i--) {
used[get<1>(mx[i])] = 1; round2.push_back(mx[i]);
}
cnt = 0;
for (int i = 0; i < n; i++) {
if (used[get<1>(mn[i])]) continue;
cnt++;
round1.push_back(mn[i]);
if (cnt == n/2) break;
}
long long ans = 0;
if (findanswer(round1) > findanswer(round2)) {
setanswer(round1);
} else setanswer(round2);
ans = max(findanswer(round1), findanswer(round2));
allocate_tickets(answer);
return ans;
}
컴파일 시 표준 에러 (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... | ||||
