제출 #822995

#제출 시각아이디문제언어결과실행 시간메모리
822995Sohsoh84Carnival Tickets (IOI20_tickets)C++17
11 / 100
1 ms596 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define all(x) (x).begin(), (x).end() #define X first #define Y second #define sep ' ' #define debug(x) cerr << #x << ": " << x << endl; const int MAXN = 1500 + 10; int n, m, PL[MAXN], PR[MAXN]; ll ans; ll find_maximum(int k, vector<vector<int>> A) { n = A.size(); m = A[0].size(); for (int i = 0; i < n; i++) sort(all(A[i])); vector<vector<int>> res; res.resize(n); for (auto& e : res) { e.resize(m); for (int& x : e) x = -1; } for (int i = 0; i < n; i++) PL[i] = 0, PR[i] = m - 1; for (int t = 0; t < k; t++) { vector<pair<int, pll>> poss; for (int i = 0; i < n; i++) { poss.push_back({i, {A[i][PL[i]], A[i][PR[i]]}}); ans -= A[i][PL[i]]; } sort(all(poss), [] (const pair<int, pll>& a, const pair<int, pll>& b) { return a.Y.Y + a.Y.X < b.Y.Y + b.Y.Y; }); /*for (auto [ind, wtf] : poss) { cerr << ind << sep << wtf.X << sep << wtf.Y << endl; } */ for (int i = 0; i < n / 2; i++) { int ind = poss[i].X; res[ind][PL[ind]++] = t; } for (int i = n / 2; i < n; i++) { int ind = poss[i].X; res[ind][PR[ind]--] = t; ans += poss[i].Y.X + poss[i].Y.Y; } } allocate_tickets(res); 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...