제출 #499822

#제출 시각아이디문제언어결과실행 시간메모리
499822benson1029카니발 티켓 (IOI20_tickets)C++14
100 / 100
1004 ms164248 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long ans1 = 0; int ptr1[1505], ptr2[1505]; int used[1505]; set<int> used2[1505]; priority_queue< pair<long long, int> > pq; vector< vector<int> > ans2; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); for(int i=0; i<n; i++) { for(int j=0; j<k; j++) { ans1 -= x[i][j]; } ptr1[i] = k-1; ptr2[i] = m-1; pq.push({x[i][ptr1[i]]+x[i][ptr2[i]], i}); } for(int i=0; i<k*(n/2); i++) { int curr = pq.top().second; ans1 += pq.top().first; pq.pop(); ptr1[curr]--; ptr2[curr]--; if(ptr1[curr] >= 0) { pq.push({x[curr][ptr1[curr]]+x[curr][ptr2[curr]], curr}); } } ans2.resize(n); for(int i=0; i<n; i++) { ans2[i].resize(m); for(int j=0; j<m; j++) { ans2[i][j] = -1; } for(int j=0; j<k; j++) used2[i].insert(j); } int tmp = 0; for(int i=0; i<n; i++) { for(int j=0; j<=ptr1[i]; j++) { while(used[tmp] == n/2) tmp++; ans2[i][j] = tmp; used[tmp]++; used2[i].erase(tmp); tmp = (tmp+1)%k; } } for(int i=0; i<n; i++) { for(int j=ptr2[i]+1; j<m; j++) { ans2[i][j] = (*used2[i].begin()); used2[i].erase(used2[i].begin()); } } allocate_tickets(ans2); return ans1; }
#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...