제출 #833018

#제출 시각아이디문제언어결과실행 시간메모리
833018Johann카니발 티켓 (IOI20_tickets)C++14
25 / 100
871 ms62824 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() long long find_maximum(int K, std::vector<std::vector<int>> x) { int N = x.size(); int M = x[0].size(); ll value = 0; vvi ans(N, vi(M, -1)); vpii A; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) A.push_back({x[i][j], i * M + j}); sort(all(A)); for (int i = 0; i < N * M / 2; ++i) value -= A[i].first; for (int i = N * M / 2; i < N * M; ++i) value += A[i].first; A.resize(N * M / 2); sort(all(A), [&](const pii &a, const pii &b) { return a.second / M < b.second / M; }); int k = 0; for (pii tmp : A) ans[tmp.second / M][tmp.second % M] = (k++ % M); for (int i = 0; i < N; ++i) { vi V; for (int j = 0; j < M; ++j) if (ans[i][j] != -1) V.push_back(ans[i][j]); sort(all(V)); reverse(all(V)); k = 0; for (int j = 0; j < M; ++j) { while (!V.empty() && k == V.back()) k++, V.pop_back(); if (ans[i][j] == -1) ans[i][j] = k++; } } allocate_tickets(ans); return value; }
#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...