Submission #1015856

#TimeUsernameProblemLanguageResultExecution timeMemory
1015856aykhnCarnival Tickets (IOI20_tickets)C++17
0 / 100
0 ms348 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define inf 0x3F3F3F3F3F3F3F3F long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer(n, vector<int> (m, -1)); vector<long long> taken(n, 0); long long s = n * k / 2; for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { if (x[i][j]) break; taken[j]++; s--; } } vector<long long> l(n, 0), r(n, 0); for (int i = 0; i < n; i++) { long long x = min(s, k - taken[i]); taken[i] += x; s -= x; taken[i] = k - taken[i]; r[i] = m - taken[i]; } assert(!s); vector<int> o(n); iota(o.begin(), o.end(), 0); long long res = 0; for (int t = 0; t < k; t++) { sort(o.begin(), o.end(), [&](const int &a, const int &b) { return r[a] < r[b]; }); for (int i = 0; i < o.size() / 2; i++) { res += x[o[i]][r[o[i]]]; answer[o[i]][r[o[i]]] = t; r[o[i]]++; } for (int i = o.size() / 2; i < o.size(); i++) { res -= x[o[i]][l[o[i]]]; answer[o[i]][l[o[i]]] = t; l[o[i]]++; } } allocate_tickets(answer); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int i = 0; i < o.size() / 2; i++)
      |                   ~~^~~~~~~~~~~~~~
tickets.cpp:48:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for (int i = o.size() / 2; i < o.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...