Submission #302669

#TimeUsernameProblemLanguageResultExecution timeMemory
302669junseoCarnival Tickets (IOI20_tickets)C++17
0 / 100
4 ms768 KiB
#include "tickets.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rmin(r, x) r = min(r, x) #define rmax(r, x) r = max(r, x) #define ends ' ' #define endl '\n' #define fastio ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int maxn = 1510; const int maxm = 1510; const int maxk = maxm; int n, m, k, l[maxn], r[maxn]; ll c[maxn][maxk]; vector<vector<int>> ans; struct Node { int i, j; Node(int i, int j) : i(i), j(j) {} }; bool operator < (Node l, Node r) { if(l.j == k) return true; if(r.j == k) return false; return c[l.i][l.j + 1] - c[l.i][l.j] < c[r.i][r.j + 1] - c[r.i][r.j]; } long long find_maximum(int _k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); k = _k; ans.resize(n); ll ret = 0; priority_queue<Node> pq; for(int i = 0; i < n; ++i) { ans[i].resize(m, -1); l[i] = 0, r[i] = m - 1; for(int j = 0; j < k; ++j) c[i][k] += -x[i][j]; for(int j = k - 1; j >= 0; --j) c[i][j] = c[i][j + 1] + x[i][j] + x[i][m - (k - j)]; pq.push({i, 0}); ret += c[i][0]; } for(int i = 0; i < n * k / 2; ++i) { Node t = pq.top(); pq.pop(); ret += (c[t.i][t.j + 1] - c[t.i][t.j]); pq.push({t.i, t.j + 1}); } vector<pii> v; while(!pq.empty()) { Node t = pq.top(); pq.pop(); v.eb(t.j, t.i); } assert(v.size() == n); for(int T = 0; T < k; ++T) { sort(all(v)); for(int i = 0; i < n; ++i) { int j = v[i].fi; if(i < n / 2) { ans[j][r[j]--] = T; } else { ans[j][l[j]++] = T; --v[j].fi; } } } allocate_tickets(ans); return ret; }

Compilation message (stderr)

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from tickets.cpp:2:
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:63:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |  assert(v.size() == n);
      |         ~~~~~~~~~^~~~
#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...