제출 #1043080

#제출 시각아이디문제언어결과실행 시간메모리
1043080MarwenElarbi카니발 티켓 (IOI20_tickets)C++17
11 / 100
1 ms860 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; #define pb push_back #define se second #define fi first long long find_maximum(int k, std::vector<std::vector<int>> x) { long long n = x.size(); int m = x[0].size(); vector<vector<int>> ans(n,vector<int> (m,-1)); priority_queue<pair<pair<int,int>,pair<int,int>>> mx; long long res=0; for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { ans[i][j]=2; } } for (int i = 0; i < n; ++i) { for (int j = m-k; j < m; ++j) { mx.push({{x[i][j],ans[i][j]},{i,j}}); } } for (int i = 0; i < k*n/2; ++i) { auto cur=mx.top(); res+=cur.fi.fi; mx.pop(); ans[cur.se.fi][cur.se.se]=3; } priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>,greater<pair<pair<int,int>,pair<int,int>>>> mn; for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { mn.push({{x[i][j],ans[i][j]},{i,j}}); } } for (int i = 0; i < k*n/2; ++i) { auto cur=mn.top(); mn.pop(); if(ans[cur.se.fi][cur.se.se]==1) continue; res-=cur.fi.fi; ans[cur.se.fi][cur.se.se]=0; } int lst[n]; memset(lst,0,sizeof lst); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if(ans[i][j]==2) ans[i][j]=-1; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if(ans[i][j]==-1) continue; ans[i][j]=lst[i]++; } } allocate_tickets(ans); return res; }
#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...