이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
struct A {
int x, i, j;
bool operator < (const A & o) const {
return x < o.x;
}
};
vector<vector<int>> answer;
priority_queue<A> heap;
int roundcnt = 0;
void setanswer (vector<int> round) {
for (int i = 0; i < round.size(); i++) {
answer[i][round[i]] = roundcnt;
}
roundcnt++;
}
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<A> 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});
}
long long sum = 0;
vector<int> round (n);
for (int i = 0; i < n; i++) sum += mx[i].x;
for (int i = 0; i < n; i++) round[i] = mx[i].j;
for (int i = 0; i < n; i++) heap.push({-mx[i].x-mn[i].x, i, mn[i].j});
int cnt = 0;
while (!heap.empty() and cnt < n/2) {
auto t = heap.top(); heap.pop();
sum += t.x;
round[t.i] = t.j;
cnt++;
}
setanswer(round);
allocate_tickets(answer);
return sum;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp: In function 'void setanswer(std::vector<int>)':
tickets.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int i = 0; i < round.size(); i++) {
| ~~^~~~~~~~~~~~~~
# | 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... |