Submission #459480

#TimeUsernameProblemLanguageResultExecution timeMemory
459480astoriaCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; long long find_maximum(int k, std::vector<std::vector<int>> x) { int N=x.size(), M=x[0].size(); vector<vector<int> > ans(N); for(int i=0; i<N; i++) ans[i].resize(M); for(int i=0; i<N; i++) for(int j=0; j<M; j++) ans[i][j] = -1; ll sum=0; priority_queue<pair<ll,pair<int,int> > > pq; //<value, <colour,ticket> > for(int i=0; i<N; i++){ for(int j=0; j<k; j++){ sum -= x[i][j]; pq.push({x[i][j]+x[i][M-k+j] , {i,j} }); ans[i][j] = 0; //'-' } } int trades = N*k/2; for(int ahc=0; ahc<trades; ahc++){ ll v = pq.top().first; int i=pq.top().second.first, j=pq.top().second.second; pq.pop(); ans[i][j]=-1; ans[i][M-k+j] = 1; //'+' sum += v; } int l[2000],r[2000]; pair<int,int> arr[2000]; for(int i=0; i<N; i++){ for(int j=0; j<M; j++){ if (ans[i][j]==1){ r[i]=M-1; arr[i].first++;} else if (ans[i][j]==0) l[i]=0; } arr[i].second = i; } for (int i=0; i<k; i++) { sort(arr, arr+N); for (int j=0; j<N; j++) { int id=arr[j].second; if (j<N/2) ans[id][l[id]++]=i; else ans[id][r[id]--]=i, arr[j].first--; } } 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:51:2: error: 'allocate_tickets' was not declared in this scope
   51 |  allocate_tickets(ans);
      |  ^~~~~~~~~~~~~~~~