Submission #432104

#TimeUsernameProblemLanguageResultExecution timeMemory
432104EnkognitCarnival Tickets (IOI20_tickets)C++14
0 / 100
8 ms9932 KiB
#include <bits/stdc++.h> #include "tickets.h" #define ll long long #define mp make_pair #define pb push_back #define pll pair<ll,ll> #define pii pair<int,int> #define fi first #define se second #define all(v) v.begin(),v.end() using namespace std; ll qq[100005]; vector<vector<pll> > a; vector<ll> mn[100005], mx[100005]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int> > answer; set<pll> s; for (int i = 0; i < n; i++) { vector<pll> vv; for (int j = 0; j < m; j++) vv.pb(mp(x[i][j], j)); qq[i]=k; sort(all(vv)); a.pb(vv); s.insert(mp(a[i].back().fi+a[i][qq[i]-1].fi, i)); } for (int i = 0; i < k*n/2; i++) { pll x=*s.begin(); s.erase(s.begin()); qq[x.se]--; if (qq[x.se]>0) s.insert(mp(a[x.se][a[x.se].size()-(k-qq[x.se])].fi+a[x.se][qq[x.se]].fi, x.se)); } answer.resize(n); for (int i = 0; i < n; i++) { answer[i].resize(m, -1); for (int j = 0; j < a[i].size(); j++) if (j<qq[i]) mn[i].pb(a[i][j].se); else if (j>=a[i].size()-(k-qq[i])) mx[i].pb(a[i][j].se); reverse(all(mn[i])); } for (int i = 0; i < k; i++) { vector<pll> vv; for (int j = 0; j < n; j++) vv.pb(mp(-mx[i].size(), i)); sort(all(vv)); for (int j = 0; j < n/2; j++) { answer[vv[j].se][mx[vv[j].se].back()]=i; mx[vv[j].se].pop_back(); } for (int j = n/2; j < n; j++) { answer[vv[j].se][mn[vv[j].se].back()]=i; mn[vv[j].se].pop_back(); } } allocate_tickets(answer); return 1; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j = 0; j < a[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~
tickets.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   49 |             if (j>=a[i].size()-(k-qq[i])) mx[i].pb(a[i][j].se);
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~
#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...