Submission #833031

#TimeUsernameProblemLanguageResultExecution timeMemory
833031mosiashvililukaCarnival Tickets (IOI20_tickets)C++14
100 / 100
708 ms136964 KiB
#include<bits/stdc++.h> #include "tickets.h" using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,K,pas,PL[1509],LIM,st[1509],lst[1509],pi; long long f[1509][1509],ANS[1509][1509]; pair <long long, long long> p[1509]; long long find_maximum(int Kk, std::vector<std::vector<int> > Xx) { /*int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); for (int j = 0; j < m; j++) { if (j < k) { row[j] = j; } else { row[j] = -1; } } answer.push_back(row); } allocate_tickets(answer);*/ K=Kk; a=Xx.size(); b=Xx[0].size(); for(i=1; i<=a; i++){ for(j=1; j<=b; j++){ f[i][j]=Xx[i-1][j-1]; } } /*for(i=1; i<=a; i++){ sort(f[i]+1,f[i]+b+1); }*/ for(i=1; i<=a; i++){ for(j=1; j<=K; j++){ pas-=f[i][j]; } } vector <pair <long long, long long> > V; for(i=1; i<=a; i++){ for(j=K; j>=1; j--){ zx=f[i][b-(K-j)]+f[i][j]; V.push_back({-zx,i}); } st[i]=0;lst[i]=b; } sort(V.begin(),V.end()); LIM=a/2LL*K; for(i=1; i<=LIM; i++){ pas+=-V[i-1].first; //cout<<V[i-1].first<<" "<<V[i-1].second<<" "<<pas<<"\n"; lst[V[i-1].second]--; PL[V[i-1].second]++; } for(i=1; i<=a; i++){ for(j=1; j<=b; j++){ ANS[i][j]=-1; } } for(ii=0; ii<K; ii++){ pi=0; for(i=1; i<=a; i++){ pi++; p[pi]={PL[i],i}; } sort(p+1,p+pi+1); for(i=a/2+1; i<=a; i++){ c=p[i].second; lst[c]++;PL[c]--; d=lst[c]; ANS[c][d]=ii; } for(i=1; i<=a/2; i++){ c=p[i].second; st[c]++; d=st[c]; ANS[c][d]=ii; } } // vector <vector <int> > ANSA; ANSA.resize(a); for(i=1; i<=a; i++){ ANSA[i-1].resize(b); for(j=1; j<=b; j++){ ANSA[i-1][j-1]=ANS[i][j]; } } allocate_tickets(ANSA); // return pas; }
#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...