제출 #302816

#제출 시각아이디문제언어결과실행 시간메모리
302816mhy908카니발 티켓 (IOI20_tickets)C++14
0 / 100
6 ms9216 KiB
#include "tickets.h" #include <bits/stdc++.h> #define mp make_pair #define eb emplace_back #define F first #define S second #define all(x) x.begin(), x.end() #define svec(x) sort(all(x)) #define press(x) x.erase(unique(all(x)), x.end()); using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<int, LL> pil; typedef pair<LL, int> pli; typedef pair<LL, LL> pll; const int INF=1e9; const LL LLINF=1e18; int n, m, k, re[1510], re2[1510], re3[1510], ans2[1510][1510]; LL arr[1510][1510], ans; priority_queue<pli> pq; LL find_maximum(int _k, vector<vector<int> > x){ n=x.size(); m=x[0].size(); k=_k; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++)arr[i][j]=(LL)x[i-1][j-1]; } for(int i=1; i<=n; i++){ for(int j=m-k+1; j<=m; j++)ans+=arr[i][j]; pq.push(mp(-arr[i][1]-arr[i][m-k+1], i)); re3[i]=m; } for(int i=1; i<=n*k/2; i++){ LL d=pq.top().F; int nw=pq.top().S; ans+=d; re[nw]++; if(re[nw]<=k)pq.push(mp(-arr[nw][re[nw]+1]-arr[nw][m-k+re[nw]+1], nw)); } memset(ans2, -1, sizeof ans2); for(int i=0; i<k; i++){ int num=0; for(int j=1; j<=n; j++){ if(re2[j]==re[j]||num==n/2){ ans2[j][re3[j]--]=i; } else{ num++; ans2[j][++re2[j]]=i; } } } vector<vector<int> > ret; for(int i=1; i<=n; i++){ vector<int> vc(m); for(int j=1; j<=m; j++)vc[j-1]=ans2[i][j]; ret.eb(vc); } allocate_tickets(ret); 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...