Submission #354512

#TimeUsernameProblemLanguageResultExecution timeMemory
354512juggernautCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include"tickets.h" #ifndef EVAL #include"stub.cpp" #endif #include<bits/stdc++.h> using namespace std; int l[1505],r[1505]; typedef long long ll; bool cmp(int x,int y){return (l[x]>l[y]);} long long find_maximum(int k,vector<vector<int> > arr) { priority_queue<pair<ll,int>>q;ll res=0; int n=arr.size(),m=arr[0].size();vector<int>ind(n); vector<vector<int>>answer(n,vector<int>(m,-1)); for(int i=0;i<n;i++){ind[i]=i; for(int j=0;j<k;j++)res-=arr[i][j]; q.push(mp(arr[i][l[i]=k-1]+arr[i][r[i]=m-1],i)); } for(int i=0;i<(n*k)>>1;i++){ int ind=q.top().ss;res+=q.top().ff;q.pop();--l[ind];--r[ind]; if(l[ind]>=0)q.push(mp(arr[ind][l[ind]]+arr[ind][r[ind]],ind)); } while(k--){sort(ind.begin(),ind.end(),cmp); for(int i=0;i<n>>1;i++)answer[ind[i]][l[ind[i]]--]=k; for(int i=n>>1;i<n;i++)answer[ind[i]][++r[ind[i]]]=k; } allocate_tickets(answer); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:16:10: error: 'mp' was not declared in this scope; did you mean 'm'?
   16 |   q.push(mp(arr[i][l[i]=k-1]+arr[i][r[i]=m-1],i));
      |          ^~
      |          m
tickets.cpp:19:19: error: 'const value_type' {aka 'const struct std::pair<long long int, int>'} has no member named 'ss'
   19 |   int ind=q.top().ss;res+=q.top().ff;q.pop();--l[ind];--r[ind];
      |                   ^~
tickets.cpp:19:35: error: 'const value_type' {aka 'const struct std::pair<long long int, int>'} has no member named 'ff'
   19 |   int ind=q.top().ss;res+=q.top().ff;q.pop();--l[ind];--r[ind];
      |                                   ^~
tickets.cpp:20:23: error: 'mp' was not declared in this scope; did you mean 'm'?
   20 |   if(l[ind]>=0)q.push(mp(arr[ind][l[ind]]+arr[ind][r[ind]],ind));
      |                       ^~
      |                       m