제출 #823046

#제출 시각아이디문제언어결과실행 시간메모리
823046Sohsoh84카니발 티켓 (IOI20_tickets)C++17
27 / 100
386 ms51328 KiB
#include "tickets.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)		(x).begin(), (x).end()
#define X		first
#define Y		second
#define sep		' '
#define debug(x)	cerr << #x << ": " << x << endl;

const int MAXN = 1500 + 10;

int n, m, PL[MAXN], PR[MAXN];
ll ans;

ll find_maximum(int k, vector<vector<int>> A) {
	n = A.size();
	m = A[0].size();

	vector<vector<int>> res;
	res.resize(n);
	for (auto& e : res) {
		e.resize(m);
		for (int& x : e)
			x = -1;
	}

	for (int i = 0; i < n; i++) {
		PL[i] = 0, PR[i] = m - 1;
		assert(is_sorted(all(A[i])));
	}

	for (int t = 0; t < k; t++) {
		vector<int> poss;
		for (int i = 0; i < n; i++) poss.push_back(i), assert(PR[i] - PL[i] == m - t - 1);

		sort(all(poss), [&A] (int i, int j) {
			return A[i][PL[i]] + A[i][PR[i]] < A[j][PL[j]] + A[j][PR[j]];
		});

		for (int i = 0; i < n / 2; i++) {
			res[poss[i]][PL[poss[i]]] = t;
			ans -= A[poss[i]][PL[poss[i]]];
			PL[poss[i]]++;
		}

		for (int i = n / 2; i < n; i++) {
			res[poss[i]][PR[poss[i]]] = t;
			ans += A[poss[i]][PR[poss[i]]];
			PR[poss[i]]--;
		}
	}

	assert(k <= 3);
	allocate_tickets(res);
	if (k > 1) return 6;
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...