# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1077974 | anango | 카니발 티켓 (IOI20_tickets) | C++17 | 1510 ms | 286768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<signed>> intify(vector<vector<int>> res) {
vector<vector<signed>> ans(res.size(),vector<signed>(res[0].size()));
for (int i=0; i<res.size(); i++) {
for (int j=0; j<res[0].size(); j++) {
ans[i][j] = res[i][j];
}
}
return ans;
}
long long find_maximum(signed k, std::vector<std::vector<signed>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> elems;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
elems.push_back({x[i][j],i,j});
}
}
sort(elems.begin(), elems.end());
vector<vector<int>> answer(n,vector<int>(m,-1));
int mid = n*m/2;
for (int i=0; i<mid; i++) {
answer[elems[i][1]][elems[i][2]] = -2; //minus
}
int sol = 0;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
if (answer[i][j]==-1) {
sol+=x[i][j];
}
else {
sol-=x[i][j];
}
}
}
//-1 is plus, -2 is minus
vector<set<int>> minus_rem(n); vector<set<int>> plus_rem(n);
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
if (answer[i][j]==-1) {
plus_rem[i].insert(j);
}
else {
minus_rem[i].insert(j);
}
}
}
for (int op=0; op<m; op++) {
int balance = 0;
set<int> rem;
for (int i=0; i<n; i++) {
if (!plus_rem[i].size()) {
answer[i][*minus_rem[i].begin()] = op;
minus_rem[i].erase(minus_rem[i].begin());
balance--;
}
else if (!minus_rem[i].size()) {
answer[i][*plus_rem[i].begin()] = op;
plus_rem[i].erase(plus_rem[i].begin());
balance++;
}
else {
rem.insert(i);
}
}
for (int i:rem) {
if (balance>=0) {
answer[i][*minus_rem[i].begin()] = op;
minus_rem[i].erase(minus_rem[i].begin());
balance--;
}
else {
answer[i][*plus_rem[i].begin()] = op;
plus_rem[i].erase(plus_rem[i].begin());
balance++;
}
}
}
allocate_tickets(intify(answer));
return sol;
}
컴파일 시 표준 에러 (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... |