Submission #1039682

#TimeUsernameProblemLanguageResultExecution timeMemory
1039682amirhoseinfar1385카니발 티켓 (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h"
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1500+10;
long long n,m,all[maxn][maxn],last[maxn];
vector<vector<int>>res;

long long find_maximum(int k, std::vector<std::vector<int>> x) {
	n = x.size();
	m = x[0].size();
	res.resize(n,vector<int>(m));
	for(long long i=0;i<n;i++){
		for(long long j=0;j<m;j++){
			all[i][j]=x[i][j];
			res[i][j]=-1;
		}
	}
	long long mainres=0;
	priority_queue<pair<long long,long long>>pq;
	for(int i=0;i<n;i++){
		for(int j=m-1;j>=m-k;j--){
			res[i][j]=1;
			mainres+=all[i][j];
		}
		pq.push(make_pair(-all[i][m-k]-all[i][0],i));
	}
	for(int i=0;i<(n*k)/2;i++){
		mainres+=pq.top().first;
		auto x=pq.top().second;
		pq.pop();
		res[x][last[x]]=1;
		res[x][m-k+last[x]]=-1;
		last[x]++;
		if(last[x]==k){
			continue;
		}
		pq.push(make_pair(-all[x][last[x]]-all[x][m-k+last[x]],x));
	}
	for(int i=0;i<n;i++){
		int cnt=0;
		for(int j=0;j<last[x];j++){
			res[i][j]=cnt;
			cnt++;
		}
		for(int j=last[x];j<m-k+last[x];j++){
			res[i][j]=-1;
		}
		for(int j=m-k+last[x];j<m;j++){
			res[i][j]=cnt;
			cnt++;
		}
	}
	allocate_tickets(res);
	return mainres;
}

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:41:21: error: no match for 'operator[]' (operand types are 'long long int [1510]' and 'std::vector<std::vector<int> >')
   41 |   for(int j=0;j<last[x];j++){
      |                     ^
tickets.cpp:45:17: error: no match for 'operator[]' (operand types are 'long long int [1510]' and 'std::vector<std::vector<int> >')
   45 |   for(int j=last[x];j<m-k+last[x];j++){
      |                 ^
tickets.cpp:45:31: error: no match for 'operator[]' (operand types are 'long long int [1510]' and 'std::vector<std::vector<int> >')
   45 |   for(int j=last[x];j<m-k+last[x];j++){
      |                               ^
tickets.cpp:48:21: error: no match for 'operator[]' (operand types are 'long long int [1510]' and 'std::vector<std::vector<int> >')
   48 |   for(int j=m-k+last[x];j<m;j++){
      |                     ^