제출 #613984

#제출 시각아이디문제언어결과실행 시간메모리
613984alirezasamimi100카니발 티켓 (IOI20_tickets)C++17
100 / 100
735 ms58324 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; using ll = long long int; #define pb push_back #define F first #define S second ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<int> l(n,k-1),r(n,m),vec; priority_queue<pii> pq; vector<vector<int>> an(n,vector<int>(m,-1)); ll ans=0; int rem=n*k/2; for(int i=0; i<n; i++){ vec.pb(i); for(int j=0; j<k; j++){ ans-=x[i][j]; } pq.push({x[i][m-1]+x[i][k-1],i}); } while(rem--){ auto [t,i]=pq.top(); pq.pop(); ans+=t; l[i]--; r[i]--; if(l[i]>=0) pq.push({x[i][r[i]-1]+x[i][l[i]],i}); } for(int i=0; i<k; i++){ sort(vec.begin(),vec.end(),[&](int &a, int &b){return l[a]>l[b];}); for(int j=0; j<n/2; j++){ an[vec[j]][l[vec[j]]]=i; l[vec[j]]--; } for(int j=n/2; j<n; j++){ an[vec[j]][r[vec[j]]]=i; r[vec[j]]++; } } allocate_tickets(an); 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...