Submission #464113

#TimeUsernameProblemLanguageResultExecution timeMemory
464113armandCarnival Tickets (IOI20_tickets)C++14
11 / 100
2 ms680 KiB
#include "tickets.h"
#include <vector>
#include <algorithm>
using namespace std;

long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	int i, j, p;
	long long res = 0;
	int b;
	std::vector<std::vector<int>> answer;
	vector<int> a(n);
	for (i = 0; i < n; i++) {
		std::vector<int> row(m);
		for (j = 0; j < m; j++) {
			if (j < k) {
				row[j] = j;
			} else {
				row[j] = -1;
			}
		}
		answer.push_back(row);
	}
	allocate_tickets(answer);
	for (j = m-1, p = 0; p<k && j>=0; j--,p++) {
		for (i = 0; i < n; i++)
			a[i] = x[i][j];
		sort(a.begin(), a.end());
		b = a[n / 2];
		for (i = 0; i < n; i++)
			res += llabs(b - a[i]);
	}
	return res;
}
#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...