Submission #930814

#TimeUsernameProblemLanguageResultExecution timeMemory
930814JooDdaeCarnival Tickets (IOI20_tickets)C++17
27 / 100
404 ms73204 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); ll ans = 0; priority_queue<array<int, 2>> pq; vector<int> c(n, 0); for(int i=0;i<n;i++) { for(int j=0;j<k;j++) ans -= x[i][j]; pq.push({x[i][m-1]+x[i][k-1], i}); } for(int i=0;i<n*k/2;i++) { auto [C, u] = pq.top(); pq.pop(); ans += C; if(++c[u] == k) continue; pq.push({x[u][m-1-c[u]]+x[u][k-1-c[u], u]}); } while(!pq.empty()) pq.pop(); vector<int> L(n, 0), R(n, 0); for(int i=0;i<n;i++) R[i] = m-c[i]; for(int i=0;i<n;i++) c[i] = k-c[i], pq.push({c[i], i}); vector<vector<int>> re(n, vector<int>(m, -1)); for(int i=0;i<k;i++) { set<int> s; for(int j=0;j<n/2;j++) s.insert(pq.top()[1]), pq.pop(); for(int j=0;j<n;j++) { if(s.count(j)) re[j][L[j]++] = i; else re[j][R[j]++] = i; } for(auto x : s) pq.push({--c[x], x}); } allocate_tickets(re); return ans; }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:22:41: warning: value computed is not used [-Wunused-value]
   22 |         pq.push({x[u][m-1-c[u]]+x[u][k-1-c[u], u]});
#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...