Submission #303020

#TimeUsernameProblemLanguageResultExecution timeMemory
303020tutisCarnival Tickets (IOI20_tickets)C++17
0 / 100
3079 ms512 KiB
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	vector<vector<int>> answer(n, vector<int>(m, -1));
	int a[n], b[n];
	for (int i = 0; i < n; i++)
	{
		a[i] = 0;
		b[i] = m - 1;
	}
	long long ret = 0;
	for (int g = 0; g < k; g++)
	{
		vector<bool>av(n, true);
		int c = n / 2;
		while (c--)
		{
			pair<int, pair<int, int>>mx = { -1, {0, 1}};
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					if (i == j || av[i] == false || av[j] == false)
						continue;
					mx = max(mx, {abs(x[i][a[i]] - x[j][b[j]]), {i, j}});
				}
			}
			ret += mx.first;
			answer[mx.second.first][a[mx.second.first]] = g;
			answer[mx.second.second][b[mx.second.second]] = g;
			a[mx.second.first]++;
			b[mx.second.second]--;
			av[mx.second.first] = false;
			av[mx.second.second] = false;
		}
	}
	allocate_tickets(answer);
	return ret;
}
#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...