제출 #300700

#제출 시각아이디문제언어결과실행 시간메모리
300700abeker카니발 티켓 (IOI20_tickets)C++17
100 / 100
1212 ms62352 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; typedef long long ll; typedef pair <int, int> pii; ll find_maximum(int K, vector <vector <int>> x) { int N = x.size(); int M = x[0].size(); ll sol = 0; vector <pii> diffs; for (int i = 0; i < N; i++) for (int j = 1; j <= K; j++) { diffs.push_back({x[i][K - j] + x[i][M - j], i}); sol -= x[i][K - j]; } sort(diffs.begin(), diffs.end(), greater <pii> ()); vector <int> cnt(N); for (int i = 0; i < K * N / 2; i++) { cnt[diffs[i].second]++; sol += diffs[i].first; } vector <int> lo(N, 0), hi(N, M - 1); vector <vector <int>> round(N, vector <int> (M, -1)); for (int k = 0; k < K; k++) { vector <pii> sorted; for (int i = 0; i < N; i++) sorted.push_back({cnt[i], i}); sort(sorted.begin(), sorted.end(), greater <pii> ()); for (int i = 0; i < N; i++) { int colour = sorted[i].second; if (i < N / 2) { round[colour][hi[colour]--] = k; cnt[colour]--; } else round[colour][lo[colour]++] = k; } } allocate_tickets(round); return sol; }
#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...