제출 #1062663

#제출 시각아이디문제언어결과실행 시간메모리
1062663TlenekWodoru카니발 티켓 (IOI20_tickets)C++14
27 / 100
475 ms81396 KiB
#include<bits/stdc++.h> #include "tickets.h" using namespace std; int Wziety[1509]; long long find_maximum(int k, vector<vector<int>>A) { int n = A.size(); int n2=n/2; int m = A[0].size(); vector<vector<int>>answer(n,vector<int>(m,-1)); vector<deque<pair<int,int>>>D; for(vector<int>U : A) { deque<pair<int,int>>T; for(int i=0;i<(int)U.size();i++) { T.push_back({U[i],i}); } sort(T.begin(),T.end()); D.push_back(T); } memset(Wziety,-1,sizeof(Wziety)); long long wynik=0; for(int i=0;i<k;i++) { vector<pair<int,int>>Opty; for(int j=0;j<n;j++) { Opty.push_back({D[j].front().first+D[j].back().first,j}); } sort(Opty.begin(),Opty.end()); for(int j=0;j<n2;j++) { Wziety[Opty[j].second]=i; } for(int j=0;j<n;j++) { if(Wziety[j]==i) { answer[j][D[j].front().second]=i; wynik-=D[j].front().first; D[j].pop_front(); } else { answer[j][D[j].back().second]=i; wynik+=D[j].back().first; D[j].pop_back(); } } } allocate_tickets(answer); return wynik; }
#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...