Submission #1078972

#TimeUsernameProblemLanguageResultExecution timeMemory
1078972Muhammad_AneeqCarnival Tickets (IOI20_tickets)C++17
11 / 100
1 ms860 KiB
#include <vector> #include <set> #include <deque> #include <algorithm> #include <iostream> using namespace std; void allocate_tickets( vector<vector<int>> _x); long long find_maximum(int k, vector<vector<int>> d) { int n=d.size(),m=d[0].size(); if (m==1) { vector<vector<int>>ans=d; vector<int>f; for (int i=0;i<n;i++) { ans[i][0]=0; f.push_back(d[i][0]); } allocate_tickets(ans); sort(begin(f),end(f)); long long z=0; for (int i=0;i<n;i++) z+=abs(f[i]-f[n/2]); return z; } if (k==1) { long long z=0; vector<int>ind(vector<int>(n,0)); vector<vector<int>>ans(n,vector<int>(m,-1)); for (int i=0;i<n;i++) { for (int j=0;j<m;j++) { set<pair<int,int>>s; for (int l=0;l<n;l++) { if (l==i) continue; if (d[l][0]<=d[i][j]) { int f=d[i][j]-d[l][0]-abs(d[l].back()-d[i][j]); s.insert({f,l}); } } set<pair<int,int>>s1; for (int l=0;l<n;l++) { if (l==i) continue; if (d[i][j]<=d[l].back()) s1.insert({d[l].back()-d[i][j],l}); } if (s.size()<n/2-1) continue; if (s1.size()<n/2-1) break; long long val=0; vector<int>mi,ma; for (int l=0;l<n/2-2;l++) { int in=(*rbegin(s)).second; mi.push_back(in); s.erase(*rbegin(s)); s1.erase({d[in].back()-d[i][j],in}); val+=d[i][j]-d[in][0]; } for (int l=0;l<2;l++) { if (s.size()==0) break; int in=(*rbegin(s)).second; mi.push_back(in); s.erase(*rbegin(s)); s1.erase({d[in].back()-d[i][j],in}); val+=d[i][j]-d[in][0]; if (s1.size()<n/2-l) continue; auto en=rend(s1); long long er=val; ma={}; for (int u=0;u<n/2-l;u++) { int in=(*en).second; ma.push_back(in); er+=(*en).first; en--; } if (er>z) { ind.resize(n,0); z=er; for (auto l:mi) ind[l]=0; for (auto l:ma) ind[l]=m-1; ind[i]=j; } } } } for (int i=0;i<n;i++) ans[i][ind[i]]=0; allocate_tickets(ans); return z; } return 0; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:55:17: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |     if (s.size()<n/2-1)
      |         ~~~~~~~~^~~~~~
tickets.cpp:57:18: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |     if (s1.size()<n/2-1)
      |         ~~~~~~~~~^~~~~~
tickets.cpp:78:19: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   78 |      if (s1.size()<n/2-l)
      |          ~~~~~~~~~^~~~~~
#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...