제출 #678470

#제출 시각아이디문제언어결과실행 시간메모리
678470cig32카니발 티켓 (IOI20_tickets)C++17
100 / 100
937 ms98140 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); for (int j = 0; j < m; j++) { row[j] = -1; } answer.push_back(row); } priority_queue<pair<int, pair<int, int> > > pq; long long ans = 0; for(int i=0; i<n; i++) { for(int j=0; j<k; j++) { ans -= x[i][j]; answer[i][j] = -2; } } for(int i=0; i<n; i++) { for(int j=m-k; j<m; j++) { pq.push({x[i][j] + x[i][j - (m-k)], {i, j}}); } } int elev = n*k / 2; while(elev--) { ans += pq.top().first; answer[pq.top().second.first][pq.top().second.second] = 1; if(m != k) answer[pq.top().second.first][pq.top().second.second - (m-k)] = -1; pq.pop(); } int nxt = 0; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { if(answer[i][j] == 1) { answer[i][j] = nxt; nxt = (nxt + 1) % k; } } } for(int i=0; i<n; i++) { bool bruh[m]; for(int j=0; j<m; j++) bruh[j] = 0; for(int j=0; j<m; j++) if(answer[i][j] >= 0) bruh[answer[i][j]] = 1; nxt = 0; for(int j=0; j<m; j++) { if(answer[i][j] == -2) { while(bruh[nxt]) nxt++; bruh[nxt] = 1; answer[i][j] = nxt; } } } allocate_tickets(answer); 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...