Submission #364789

#TimeUsernameProblemLanguageResultExecution timeMemory
364789wind_reaper카니발 티켓 (IOI20_tickets)C++17
0 / 100
1 ms384 KiB
#include "tickets.h"
#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>> ans(n, vector<int>(m, -1));
 
	long long a = 0; 
 
	for(int i = 0; i < n; i++){
		for(int j = m-1; j >= m-k; --j){
			ans[i][j] = (m-1-j);
			a += 1LL*x[i][j];
		}
	}
 
	vector<array<int, 4>> b;
 
	for(int i = 0; i < n; i++){
		for(int j = 0; j < k; j++)
			for(int w = m-1; w >= m-k; --w)
				b.push_back({x[i][j] + x[i][w], i, j, w});
	}
 
	sort(b.begin(), b.end()); 
	for(auto& [red, row, mn, mx] : b){
		if(ans[row][mx] == -1 && ans[row][mn] != -1){
			a += 1LL*red;
			swap(ans[row][mx], ans[row][mn]);
		}
		if(ans[row][mx] == -1 || ans[row][mn] != -1)
			continue;
		a -= 1LL*red;
		swap(ans[row][mx], ans[row][mn]);
	}
 
	allocate_tickets(ans);
	return a;
}
/*
for every i, j < k exchange the i th minimum and j th maximum 
each exchange costs x[i] + x[j] ... take the first nk/2 valid exchanges
 
the actual order of the stuff doesnt matter
you wanna choose nk/2 pairs to remove
 
what happens when the stuff starts to overlap

...|..|...
..|.|..
*/ 
#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...