Submission #397160

#TimeUsernameProblemLanguageResultExecution timeMemory
397160AntekbCarnival Tickets (IOI20_tickets)C++14
27 / 100
640 ms51312 KiB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
typedef pair<int, int> pii;
typedef long long ll;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	int ile[n], ile2[n];
	for(int i=0; i<n; i++){
		ile[i]=0;
		ile2[i]=m-1;
	}
	ll ans=0;
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row(m);
		answer.pb(row);
	}
	for(int i=1; i<=k; i++){
		vector<pair<int, int> > V;
		for(int j=0; j<n; j++){
			V.pb(mp(x[j][ile[j]]+x[j][ile2[j]], j));
		}
		sort(V.begin(), V.end());
		for(int j=0; j<n/2; j++){
			ans-=x[V[j].nd][ile[V[j].nd]];
			answer[V[j].nd][ile[V[j].nd]]=i;
			ile[V[j].nd]++;
		}
		for(int j=n/2; j<n; j++){
			ans+=x[V[j].nd][ile2[V[j].nd]];
			answer[V[j].nd][ile2[V[j].nd]]=i;
			ile2[V[j].nd]--;
		}
	}
	for(auto &i:answer){
		for(auto &j:i)j--;
	}
	allocate_tickets(answer);
	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...