이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
matrix<int> group(n,vector<int>(m,-1));
ll resp = 0;
vector<int> minuscount(n,k);
priority_queue<pii> pq;
for(int i = 0; i < n; i++){
for(int j = 0; j < k; j++){
resp-=x[i][j];
pq.push({x[i][j]+x[i][m+j-k],i});
}
}
for(int i = 0; i < n*k/2; i++){
pii cur = pq.top();
pq.pop();
resp+=cur.ff;
minuscount[cur.ss]--;
}
vector<pii> minus, plus;
minus.reserve(n*k/2);
plus.reserve(n*k/2);
for(int i = 0; i < n; i++){
for(int j = 0; j < minuscount[i]; j++){
minus.push_back({i,j});
}
for(int j = m-1; j >= m-(k-minuscount[i]); j--){
plus.push_back({i,j});
}
}
vector<set<int>> occupy(k);
vector<int> curid(n);
for(pii i : plus){
while(!(occupy[curid[i.ff]].size() < n/2 && !occupy[curid[i.ff]].count(i.ff))){
curid[i.ff]++;
}
occupy[curid[i.ff]].insert(i.ff);
group[i.ff][i.ss] = curid[i.ff];
curid[i.ff]++;
}
fill(all(curid),0);
for(pii i : minus){
while(!(occupy[curid[i.ff]].size() < n && !occupy[curid[i.ff]].count(i.ff))){
curid[i.ff]++;
assert(curid[i.ff] < k);
}
occupy[curid[i.ff]].insert(i.ff);
group[i.ff][i.ss] = curid[i.ff];
curid[i.ff]++;
}
allocate_tickets(group);
return resp;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:65:44: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
65 | while(!(occupy[curid[i.ff]].size() < n/2 && !occupy[curid[i.ff]].count(i.ff))){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
tickets.cpp:74:44: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
74 | while(!(occupy[curid[i.ff]].size() < n && !occupy[curid[i.ff]].count(i.ff))){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
# | 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... |