이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
/*
void allocate_tickets(vector<vector<int>> arr) {
	for(auto v : arr) {
		for(auto n : v) {
			cout << n << " ";
		}
		cout << "\n";
	}
	cout << endl;
}
*/
long long find_maximum(int K, vector<vector<int>> arr) {
	int N = arr.size();
	int M = arr[0].size();
	int G = M - K;
	long long ans = 0;
	vector<vector<int>> ret;
	vector<vector<int>> typ;
	ret.resize(N);
	typ.resize(N);
	priority_queue<pair<int, pair<int, int>>> pq;
	for(int i = 0; i < N; i++) {
		ret[i].resize(M, -1);
		typ[i].resize(M);
		for(int j = M - 1; j >= M - K; j--) {
			ans += arr[i][j];
			pq.push(make_pair(-arr[i][j] - arr[i][j-G], make_pair(i, j)));
			typ[i][j] = 1;
		}
	}
	int tot = N * K / 2;
	while(tot--) {
		auto p = pq.top();
		ans += p.first;
		typ[p.second.first][p.second.second] = 0;
		typ[p.second.first][p.second.second-G] = -1;
		pq.pop();
	}
	vector<pair<int, int>> cnt(N);
	vector<int> tkn(N);
	for(int i = 0; i < N; i++) {
		int c = 0;
		for(int j = 0; j < M; j++) {
			if(typ[i][j] == 1) {
				c++;
			}
		}
		cnt[i] = make_pair(c, i);
	}
	for(int k = 0; k < K; k++) {
		sort(cnt.begin(), cnt.end());
		for(int n = 0; n < N / 2; n++) {
			auto p = cnt[n];
			ret[p.second][k - tkn[p.second]] = k;
		}
		for(int n = N/2; n < N; n++) {
			pair<int,int>& p = cnt[n];
			//cout << p.second << " " << M-1-tkn[p.second] << endl;
			ret[p.second][M-1-tkn[p.second]] = k;
			tkn[p.second]++;
			p.first--;
		}
	}
	allocate_tickets(ret);
	return ans;
}
| # | 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... |