제출 #392914

#제출 시각아이디문제언어결과실행 시간메모리
392914phathnv카니발 티켓 (IOI20_tickets)C++17
100 / 100
926 ms75884 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer(n, vector<int>(m, -1)); vector<int> numMinus(n, k); priority_queue<pair<int, int>> pq; for(int i = 0; i < n; i++) pq.push({x[i][numMinus[i] - 1] + x[i][m - k + numMinus[i] - 1], i}); for(int i = 0; i < k * n / 2; i++){ int row = pq.top().second; pq.pop(); numMinus[row]--; if (numMinus[row] > 0) pq.push({x[row][numMinus[row] - 1] + x[row][m - k + numMinus[row] - 1], row}); } int plusPtr = 0, minusPtr = k - 1; long long total = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < numMinus[i]; j++){ answer[i][j] = minusPtr; minusPtr = (minusPtr == 0? k - 1 : minusPtr - 1); total -= x[i][j]; } for(int j = m - k + numMinus[i]; j < m; j++){ answer[i][j] = plusPtr; plusPtr = (plusPtr == k - 1? 0 : plusPtr + 1); total += x[i][j]; } } allocate_tickets(answer); return total; }
#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...