Submission #426834

#TimeUsernameProblemLanguageResultExecution timeMemory
426834zoooma13Carnival Tickets (IOI20_tickets)C++14
11 / 100
2 ms716 KiB
#include "bits/stdc++.h" #include "tickets.h" using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); assert(m == k); vector <array <int ,3>> all; //{val ,color ,index} for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) all.push_back({x[i][j] ,i ,j}); sort(all.begin() ,all.end()); int64_t tot = 0; vector<vector<int>> answer(n ,vector<int>(m ,-1)); set <int> mex[n]; for(int i = 0; i < k; i++) for(int c = 0; c < n; c++) mex[c].insert(i); vector <int> sizes(k); set <int> mexsizes; for(int i = 0; i < k; i++) mexsizes.insert(i); for(int i = 0; i < (int)all.size()/2; i++){ tot -= all[i][0]; int p = max(*mex[all[i][1]].begin() ,*mexsizes.begin()); sizes[p]++; if(sizes[p] == n/2) mexsizes.erase(p); mex[all[i][1]].erase(p); answer[all[i][1]][all[i][2]] = p; } for(int i = (int)all.size()/2; i < all.size(); i++){ tot += all[i][0]; int p = *mex[all[i][1]].begin(); mex[all[i][1]].erase(p); answer[all[i][1]][all[i][2]] = p; } allocate_tickets(answer); return tot; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:35:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = (int)all.size()/2; i < all.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...