Submission #601291

#TimeUsernameProblemLanguageResultExecution timeMemory
601291definitelynotmeeCarnival Tickets (IOI20_tickets)C++17
27 / 100
490 ms51388 KiB
#include "tickets.h" #include <vector> #include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define all(x) x.begin(), x.end() #define ff first #define ss second using namespace std; template <typename T> using matrix = vector<vector<T>>; typedef unsigned int uint; typedef unsigned long long ull; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 1e9 + 7; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); const int MAXN = 1e6+1; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); matrix<int> group(n,vector<int>(m,-1)); ll resp = 0; vector<int> minuscount(n,k); priority_queue<pii> pq; for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ resp-=x[i][j]; pq.push({x[i][j]+x[i][m+j-k],i}); } } for(int i = 0; i < n*k/2; i++){ pii cur = pq.top(); pq.pop(); resp+=cur.ff; minuscount[cur.ss]--; } vector<pii> minus, plus; minus.reserve(n*k/2); plus.reserve(n*k/2); for(int i = 0; i < n; i++){ for(int j = 0; j < minuscount[i]; j++){ minus.push_back({i,j}); } for(int j = m-1; j >= m-(k-minuscount[i]); j--){ plus.push_back({i,j}); } } assert(minus.size() ==n*k/2); assert(plus.size() == n*k/2); vector<set<int>> occupy(k); vector<int> curid(n); for(pii i : plus){ while(!(occupy[curid[i.ff]].size() < n/2 && !occupy[curid[i.ff]].count(i.ff))){ curid[i.ff]++; } occupy[curid[i.ff]].insert(i.ff); group[i.ff][i.ss] = curid[i.ff]; curid[i.ff]++; } fill(all(curid),0); for(pii i : minus){ while(!(occupy[curid[i.ff]].size() < n && !occupy[curid[i.ff]].count(i.ff))){ curid[i.ff]++; assert(curid[i.ff] < k); } occupy[curid[i.ff]].insert(i.ff); group[i.ff][i.ss] = curid[i.ff]; curid[i.ff]++; } allocate_tickets(group); return resp; }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from tickets.cpp:3:
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:60:25: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     assert(minus.size() ==n*k/2);
      |            ~~~~~~~~~~~~~^~~~~~~
tickets.cpp:61:24: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |     assert(plus.size() == n*k/2);
      |            ~~~~~~~~~~~~^~~~~~~~
tickets.cpp:67:44: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |         while(!(occupy[curid[i.ff]].size() < n/2 && !occupy[curid[i.ff]].count(i.ff))){
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
tickets.cpp:76:44: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   76 |         while(!(occupy[curid[i.ff]].size() < n && !occupy[curid[i.ff]].count(i.ff))){
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#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...