Submission #401258

#TimeUsernameProblemLanguageResultExecution timeMemory
401258my99nCarnival Tickets (IOI20_tickets)C++14
27 / 100
708 ms54632 KiB
#include "tickets.h" #include <bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; struct A { int x, i, j; bool operator < (const A & o) const { return x < o.x; } }; vector<vector<int>> answer; priority_queue<A> heap; int roundcnt = 0; void setanswer (vector<int> round) { for (int i = 0; i < round.size(); i++) { answer[i][round[i]] = roundcnt; } roundcnt++; } long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); answer = vector<vector<int>>(n); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { answer[i].push_back(-1); } } vector<A> mn, mx; for (int i = 0; i < n; i++) { vector<pair<int,int>> temp; for (int j = 0; j < m; j++) { temp.push_back({x[i][j], j}); } sort(all(temp)); mn.push_back({temp[0].first, i, temp[0].second}); mx.push_back({temp.back().first, i, temp.back().second}); } long long sum = 0; vector<int> round (n); for (int i = 0; i < n; i++) sum += mx[i].x; for (int i = 0; i < n; i++) round[i] = mx[i].j; for (int i = 0; i < n; i++) heap.push({-mx[i].x-mn[i].x, i, mn[i].j}); int cnt = 0; while (!heap.empty() and cnt < n/2) { auto t = heap.top(); heap.pop(); sum += t.x; round[t.i] = t.j; cnt++; } setanswer(round); allocate_tickets(answer); return sum; }

Compilation message (stderr)

tickets.cpp: In function 'void setanswer(std::vector<int>)':
tickets.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int i = 0; i < round.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...