Submission #384980

#TimeUsernameProblemLanguageResultExecution timeMemory
384980Ahmadsm2005Carnival Tickets (IOI20_tickets)C++14
11 / 100
3 ms748 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "tickets.h" using namespace std; long long find_maximum(int k,vector<vector<int>> x) { int n = x.size(); long long CNT=0; int m = x[0].size(); vector<vector<int>>answer(n); for(int i=0;i<n;i++) for(int l=0;l<m;l++) answer[i].push_back(-1); set<pair<int,pair<int,int>>>lol; set<int>VIS; vector<pair<int,pair<int,int>>>TEMP,TEMP2; for(int i=0;i<n;i++){ for(int l=0;l<m;l++){ lol.insert({x[i][l],{i,l}}); } } int Z=0; int N=n; while(N){ auto itr=lol.end(),itr2=lol.begin(); itr--; while(VIS.find((itr->second).first)!=VIS.end()) itr--; VIS.insert((itr->second).first); while(VIS.find((itr2->second).first)!=VIS.end()) itr2++; int DIFF=((itr->first)-(itr2->first)); VIS.erase((itr->second).first); itr=lol.end(),itr2=lol.begin(); itr--; while(VIS.find((itr2->second).first)!=VIS.end()) itr2++; VIS.insert((itr2->second).first); while(VIS.find((itr->second).first)!=VIS.end()) itr--; bool YAY=0; if(((itr->first)-(itr2->first))>DIFF){ YAY=1; } else{ VIS.erase((itr2->second).first); itr=lol.end(),itr2=lol.begin(); itr--; while(VIS.find((itr->second).first)!=VIS.end()) itr--; VIS.insert((itr->second).first); while(VIS.find((itr2->second).first)!=VIS.end()) itr2++; } TEMP.push_back({(itr->first),{(itr->second).first,(itr->second).second}}); TEMP.push_back({(itr2->first),{(itr2->second).first,(itr2->second).second}}); if(YAY) VIS.insert((itr->second).first); else VIS.erase((itr2->second).first); lol.erase(itr),lol.erase(itr2); N-=2; } Z++; sort(TEMP.begin(),TEMP.end()); int X=TEMP[(TEMP.size()-1)/2].first; for(int i=0;i<TEMP.size();i++){ CNT+=abs(TEMP[i].first-X); } for(int i=0;i<TEMP.size();i++) answer[TEMP[i].second.first][TEMP[i].second.second]=0; long long MAXER=CNT; allocate_tickets(answer); return MAXER; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:66:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 | for(int i=0;i<TEMP.size();i++){
      |             ~^~~~~~~~~~~~
tickets.cpp:69:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 | for(int i=0;i<TEMP.size();i++)
      |             ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...