Submission #672673

#TimeUsernameProblemLanguageResultExecution timeMemory
672673tbzardCarnival Tickets (IOI20_tickets)C++14
27 / 100
588 ms73040 KiB
#include <bits/stdc++.h> using namespace std; void allocate_tickets(vector<vector<int> > s); long long find_maximum(int k, vector<vector<int> > x){ int n = x.size(), m = x[0].size(); vector<vector<int> > s(n); for(int i=0;i<n;i++) s[i].resize(m); long long ans = -1; vector<int> hi; int idx = -1; vector<pair<pair<int, int>, int> > y; for(int i=0;i<n;i++){ y.push_back(make_pair(make_pair(x[i][0], x[i][m-1]), i)); } sort(y.begin(), y.end()); for(int i=n/2-1;i<y.size();i++){ int val = y[i].first.first; long long res = 0; int rem = i-(n/2-1); vector<pair<int, int> > best; for(int j=0;j<i;j++){ res += val-y[j].first.first; best.push_back(make_pair((y[j].first.second-val)-(val-y[j].first.first), y[j].second)); } sort(best.begin(), best.end()); reverse(best.begin(), best.end()); vector<int> hii; for(int j=0;j<rem;j++){ res += best[j].first; hii.push_back(best[j].second); } for(int j=i+1;j<n;j++){ res += y[j].first.second - val; hii.push_back(y[j].second); } if(ans < res){ ans = res; hi = hii; idx = i; } } for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ s[i][j] = -1; } } for(int i=0;i<n/2;i++){ s[hi[i]][m-1] = 0; } for(int i=0;i<n;i++){ if(s[i][m-1] == -1) s[i][0] = 0; } allocate_tickets(s); return ans; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=n/2-1;i<y.size();i++){
      |                     ~^~~~~~~~~
tickets.cpp:13:9: warning: variable 'idx' set but not used [-Wunused-but-set-variable]
   13 |     int idx = -1;
      |         ^~~
#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...