Submission #460328

#TimeUsernameProblemLanguageResultExecution timeMemory
460328wind_reaperCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "tickets.h"

using namespace std;

long long find_maximum(int k, vector<vector<int>> x){
	int N = x.size(), M = x[0].size();

	int ans[N][M];
	memset(ans, -1, sizeof ans);

	long long sum = 0;

	priority_queue<array<int64_t, 3>> pq;

	for(int i = 0; i < N; i++){
		for(int j = 0; j < k; j++){
			pq.push({x[i][j] +  x[i][M-k+j], i, j});
			ans[i][j] = 0;
		}
	}

	for(int _ = 0; _ < (N * K) / 2; _++){
		auto [v, i, j] = pq.top();
		pq.pop();
		sum += v;
		ans[i][j] = -1;
		ans[i][M + k - j] = 1;
	}

	int l[N], r[N]; array<int, 2> arr[N];

	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			if(ans[i][j] == 1){
				arr[i][0]++;
			}
		}
		arr[i][1] = i;
		l[i] = 0;
		r[i] = M - 1;
	}

	for(int i = 0; i < k; i++){
		sort(arr, arr + N);
		for(int j = 0; j < N; j++){
			int col = arr[j][1];
			if(j < N / 2) ans[col][l[col]++] = i;
			else{
				ans[col][r[col]--] = i;
				arr[j][0]--;
			}
		}
	}
	
	allocate_tickets(ans);
	return sum;	
}

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:23:26: error: 'K' was not declared in this scope
   23 |  for(int _ = 0; _ < (N * K) / 2; _++){
      |                          ^
tickets.cpp:56:19: error: could not convert '(int (*)[M])(& ans)' from 'int (*)[M]' to 'std::vector<std::vector<int> >'
   56 |  allocate_tickets(ans);
      |                   ^~~
      |                   |
      |                   int (*)[M]