Submission #1062896

#TimeUsernameProblemLanguageResultExecution timeMemory
1062896jamjanekCarnival Tickets (IOI20_tickets)C++14
27 / 100
344 ms73060 KiB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;

void usun(vector<int>&ile, set<pair<int, int>>&ilejedynek, int x){
	pair<int,int> it = {ile[x], x};
	ilejedynek.erase(it);
	ile[it.second]--;
	ilejedynek.insert({it.first-1, it.second});
	
}

long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	int i, j;

	vector<vector<int>>answer = x;
	vector<pair<long long, int>>srednie;
	vector<int>pozmini(n), pozmaxi(n);
	for(i=0;i<n;i++){
		int mini = x[i][0], maxi = x[i][0];
		for(j=1;j<m;j++)
			mini = min(mini, x[i][j]), maxi = max(maxi, x[i][j]);
		for(j=0;j<m;j++){
			answer[i][j] = -1;
			if(mini==x[i][j])
				pozmini[i] = j;
			if(maxi==x[i][j])
				pozmaxi[i] = j;
		}
		srednie.push_back({(long long)mini+maxi, i});
	}
	sort(srednie.begin(), srednie.end());
	long long wynik = 0;
	for(i=0;i<n;i++){
		int j = srednie[i].second;
		if(i<n/2){
			answer[j][pozmini[j]] = 0; 
			wynik-=x[j][pozmini[j]];
		}
		else{
			answer[j][pozmaxi[j]] = 0; 
			wynik+=x[j][pozmaxi[j]];
		}
	}
	allocate_tickets(answer);
	return wynik;
	
}
#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...