Submission #300547

#TimeUsernameProblemLanguageResultExecution timeMemory
300547kevleeCarnival Tickets (IOI20_tickets)C++17
100 / 100
1555 ms102392 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mod 1000000007 #define inf 1000000000 #define ll long long #define fi first #define se second #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vp vector<pii> #define SET(a, b) memset(a, b, sizeof(a)) #define all(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) priority_queue <pair<ll, pii> > pq; bool used[1505][1505]; int cnt[1505], l[1505], r[1505]; vi v[1505]; pii a[1505]; long long find_maximum(int k, vector<vi> x) { int n = x.size(); int m = x[0].size(); vector <vi> answer; vi row(m, -1); FOR(i, 0, n-1) { answer.pb(row); } ll sum = 0; FOR(i, 0, n-1) { FOR(j, m-k, m-1) { sum += x[i][j]; pq.push({-x[i][j] - x[i][j-m+k], {i, j-m+k}}); } } FOR(i, 0, n*k/2 - 1) { auto tmp = pq.top(); pq.pop(); cnt[tmp.se.fi]++; v[tmp.se.fi].pb(tmp.se.se); answer[tmp.se.fi][tmp.se.se] = inf; sum += tmp.fi; } FOR(i, 0, n-1) { r[i] = k-1; FORD(j, m-1, m-k) { if (answer[i][j] == -1 && (int)v[i].size() < k) { v[i].pb(j); } } } FOR(i, 0, k-1) { FOR(j, 0, n-1) { a[j] = {cnt[j], j}; } sort(a, a+n); reverse(a, a+n); FOR(j, 0, n/2-1) { answer[a[j].se][v[a[j].se][l[a[j].se]]] = i; l[a[j].se]++; cnt[a[j].se]--; } FOR(j, n/2, n-1) { answer[a[j].se][v[a[j].se][r[a[j].se]]] = i; r[a[j].se]--; } } allocate_tickets(answer); return sum; }
#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...