Submission #1348527

#TimeUsernameProblemLanguageResultExecution timeMemory
1348527Faisal_Saqib카니발 티켓 (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1501;
int cnt[N];
vector<int> add[N],mns[N];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	std::vector<std::vector<int>> answer;
	vector<pair<int,int>> full;
	for (int i = 0; i < n; i++) {
		cnt[i]=0;
		add[i].clear();
		mns[i].clear();
		std::vector<int> row(m,-1);
		for(int j=0;j<m;j++)
		{
			use[i][j]=0;
			full.push_back({x[i][j],i*m+j});
		}
		answer.push_back(row);
	}
	sort(begin(full),end(full));
	// we need to take maximum n/2 *k 
	ll ans=0;
	int tot=n/2 * k;
	for(int i=full.size()-1;i>=0;i--)
	{
		int col=full[i].second/m;
		if(cnt[col]<k and tot>0)
		{
			tot--;
			ans+=full[i].first;
			cnt[col]++;
			add[col].push_back(full[i].second%m);
		}
	}
	tot=n/2 * k;
	for(int i=0;i<full.size();i++)
	{
		int col=full[i].second/m;
		if(cnt[col]<k and tot>0)
		{
			tot--;
			ans-=full[i].first;
			cnt[col]++;
			mns[col].push_back(full[i].second%m);
		}
	}
	int l=0;
	for(int i=0;i<n;i++)
	{
		for(auto j:add[i])
		{
			answer[i][j]=(l++)%k;
		}
		int r=l;
		for(auto j:mns[i])
		{
			answer[i][j]=(r++)%k;
		}
	}
	allocate_tickets(answer);
	return ans;
}

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:21:25: error: 'use' was not declared in this scope; did you mean 'pause'?
   21 |                         use[i][j]=0;
      |                         ^~~
      |                         pause