제출 #300900

#제출 시각아이디문제언어결과실행 시간메모리
300900Sorting카니발 티켓 (IOI20_tickets)C++17
27 / 100
790 ms51704 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> c(n, vector<int>(m, -1)); int iter = n / 2 * k; priority_queue<array<int, 2>, vector<array<int, 2>>, greater<array<int, 2>>> pq; long long ans = 0; vector<int> pos(n, 0); for(int i = 0; i < n; ++i) for(int j = m - k; j < m; ++j) ans += x[i][j]; for(int i = 0; i < n; ++i) pq.push({x[i][0] + x[i][m - k], i}); for(int i = 0; i < iter; ++i){ auto [sub, idx] = pq.top(); pq.pop(); ans -= sub; pos[idx]++; if(pos[idx] + m - k < m) pq.push({x[idx][pos[idx]] + x[idx][pos[idx] + m - k], idx}); } vector<int> cnt1(m, 0), cnt2(m, 0); for(int i = 0; i < n; ++i){ vector<bool> vis(m, false); int j2 = 0, j3 = pos[i] + m - k; for(int j = 0; j < k; ++j){ if(cnt1[j] == n / 2){ cnt2[j]++; c[i][j3] = j; j3++; vis[j] = true; } else if(cnt2[j] == n / 2){ cnt1[j]++; c[i][j2] = j; j2++; vis[j] = true; } } for(int j = 0; j < k; ++j){ if(vis[j]) continue; if(j3 != m){ cnt2[j]++; c[i][j3] = j; j3++; } else{ cnt1[j]++; c[i][j2] = j; j2++; } } } allocate_tickets(c); 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...