제출 #672695

#제출 시각아이디문제언어결과실행 시간메모리
672695tbzard카니발 티켓 (IOI20_tickets)C++14
100 / 100
933 ms62192 KiB
#include <bits/stdc++.h> using namespace std; void allocate_tickets(vector<vector<int> > s); long long find_maximum(int k, vector<vector<int> > x){ int n = x.size(), m = x[0].size(); vector<vector<int> > s(n); vector<int> num(n), l(n), r(n); for(int i=0;i<n;i++){ s[i].resize(m); r[i] = m-1; for(int j=0;j<m;j++) s[i][j] = -1; } long long ans = 0; priority_queue<pair<int, int> > pq; for(int i=0;i<n;i++){ for(int j=k-1;j>=0;j--){ pq.push(make_pair(x[i][j]+x[i][m-1-(k-1-j)], i)); ans += -x[i][j]; } } for(int i=0;i<n*k/2;i++){ int val = pq.top().first, j = pq.top().second; pq.pop(); ans += val; num[j]++; } for(int i=0;i<k;i++){ vector<pair<int, int> > v; for(int j=0;j<n;j++) v.push_back(make_pair(num[j], j)); sort(v.begin(), v.end()); reverse(v.begin(), v.end()); for(int j=0;j<n/2;j++){ int idx = v[j].second; s[idx][r[idx]--] = i; num[idx]--; } for(int j=n/2;j<n;j++){ int idx = v[j].second; s[idx][l[idx]++] = i; } } allocate_tickets(s); 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...