제출 #1062560

#제출 시각아이디문제언어결과실행 시간메모리
1062560new_acc카니발 티켓 (IOI20_tickets)C++14
25 / 100
526 ms84768 KiB
#include "tickets.h" #include <bits/stdc++.h> #define se second #define fi first using namespace std; typedef long long ll; typedef vector<int> vi; const int N=2e3+10; int t[N]; pair<int,int> r[N]; ll find_maximum(int k, vector<vi> x) { int n=x.size(); int m=x[0].size(); vector<vi> ans=x; vector<pair<int,int>> pom; for(int i=1;i<=n;i++){ r[i]={0,m-1}; for(int i2=1;i2<=m;i2++){ pom.push_back({x[i-1][i2-1],i}); } } sort(pom.begin(),pom.end()); ll res=0; for(int i=0;i<(int)pom.size()/2;i++){ res-=pom[i].fi; t[pom[i].se]++; } for(int i=(int)pom.size()/2;i<(int)pom.size();i++) res+=pom[i].fi; for(int i=1;i<=k;i++){ int il=0; vi zos; for(int i2=1;i2<=n;i2++){ if(t[i2]==0){ il++; ans[i2-1][r[i2].se--]=i-1; continue; } if(t[i2]==m-i+1){ t[i2]--,il--; ans[i2-1][r[i2].fi++]=i-1; continue; } zos.push_back(i2); } for(auto u:zos){ if(il>0){ t[u]--,il--; ans[u-1][r[u].fi++]=i-1; }else{ il++; ans[u-1][r[u].se--]=i-1; } } } 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...