Submission #319948

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3199482020-11-06 21:55:52eriksuenderhaufCarnival Tickets (IOI20_tickets)C++17
100 / 100
1508 ms107920 KiB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int,int> a[2000][2000];
int cnt[2000], vis[2000], cnt2[2000];
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size(), m = x[0].size();
vector<vector<int>> y(n, vector<int>(m, -1));
priority_queue<array<int,2>> pq;
ll ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
a[i][j] = make_pair(x[i][j], j);
sort(a[i], a[i]+m);
for (int j1 = k-1, j2 = m-1; ~j1; j1--, j2--)
pq.push({a[i][j1].first + a[i][j2].first, i}), ans -= a[i][j1].first;
}
for (int i = 0; i < k * n / 2; i++, pq.pop())
ans += pq.top()[0], cnt[pq.top()[1]]++;
while (!pq.empty()) pq.pop();
for (int i = 0; i < n; i++)
pq.push({cnt[i], i});
for (int i = 0; i < k; i++) {
for (int j = 0; j < n / 2; j++, pq.pop())
vis[pq.top()[1]] = 1;
for (int j = 0; j < n; j++) {
if (vis[j]) {
vis[j] = 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...