제출 #672693

#제출 시각아이디문제언어결과실행 시간메모리
672693tbzard카니발 티켓 (IOI20_tickets)C++14
27 / 100
449 ms51384 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); for(int i=0;i<n;i++){ s[i].resize(m); 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; for(int k=m-1;k>=0;k--){ if(s[idx][k] == -1){ s[idx][k] = i; break; } } } for(int j=n/2;j<n;j++){ int idx = v[j].second; for(int k=0;k<m;k++){ if(s[idx][k] == -1){ s[idx][k] = i; break; } } } } 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...