제출 #1198322

#제출 시각아이디문제언어결과실행 시간메모리
1198322lrnnz카니발 티켓 (IOI20_tickets)C++17
27 / 100
336 ms52788 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include "tickets.h" using namespace std; #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() #define ll long long #define ld long double #define ui uint64_t #define cont(set, element) ((set).find(element) != (set).end()) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z){ for (const T& x : Z) cout << x << ' '; cout << "\n"; } void printVariable(const any& var) { if (!var.has_value()) { cout << "null"; return; } if (var.type() == typeid(int)) { cout << any_cast<int>(var); } else if (var.type() == typeid(double)) { cout << any_cast<double>(var); } else if (var.type() == typeid(float)) { cout << any_cast<float>(var); } else if (var.type() == typeid(char)) { cout << any_cast<char>(var); } else if (var.type() == typeid(bool)) { cout << (any_cast<bool>(var) ? "true" : "false"); } else if (var.type() == typeid(string)) { cout << any_cast<string>(var); } else if (var.type() == typeid(const char*)) { cout << any_cast<const char*>(var); } else if (var.type() == typeid(long long)) { cout << any_cast<long long>(var); } else { cout << "[unknown type]"; } } template<typename... Args> void outval(Args... args) { vector<any> variables = {args...}; for (size_t i = 0; i < variables.size(); ++i) { printVariable(variables[i]); if (i != variables.size() - 1) { cout << " "; } } cout << "\n"; } #define nl "\n" #define sp << " " << /********* DEBUG *********/ const ll MOD = 1000000007; const ll inf = 1e18; const ll mxN = 1000005; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<int> takeright(n); // [val = hi unused + hi used, idx] priority_queue<pair<int,int>> pq; ll ans = 0; for (int i = 0; i < n; i++){ pq.push({x[i][k-1] + x[i][m-1] , i}); for (int j = 0; j < k; j++) ans -= x[i][j]; } ll rs = 0; while (rs < n*k/2){ auto [val, idx] = pq.top(); pq.pop(); ans += val; ++takeright[idx]; if (takeright[idx] < k) pq.push({x[idx][k-1-takeright[idx]] + x[idx][n-1-takeright[idx]], idx}); rs++; } vector<vector<int>> alloc(n, vector<int>(m, -1)); priority_queue<pair<int,int>> allocq; for (int i = 0; i < n; i++){ allocq.push({takeright[i], i}); } vector<int> lptr(n); vector<bool> use(n); for (int i = 0; i < k; i++){ fill(all(use), false); for (int j = 0; j < n/2; j++){ auto [val, idx] = allocq.top(); allocq.pop(); use[idx] = true; } for (int j = 0; j < n; j++){ if (use[j]){ alloc[j][m-takeright[j]] = i; takeright[j]--; allocq.push({takeright[j], j}); } else{ alloc[j][lptr[j]] = i; lptr[j]++; } } } allocate_tickets(alloc); return ans; }
#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...