Submission #1029598

#TimeUsernameProblemLanguageResultExecution timeMemory
1029598happy_nodeCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms436 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long find_maximum(int k, std::vector<std::vector<int>> d) { int N=d.size(); int M=d[0].size(); for(int i=0;i<N;i++) { for(int j=0;j<M;j++) { assert(d[i][j]<=1 && 0<=d[i][j]); } } vector<int> vals; for(int j=0;j<M;j++) { int s=0; for(int i=0;i<N;i++) s+=d[i][j]; vals.push_back(min(s,N-s)); } int sum=0; for(int j=M-1;j>=M-k;j--) sum+=vals[j]; int curOpt=sum, opt=-1; for(int j=0;j<k;j++) { // [0,j] U [M-k+j+1,M-1] if(j>=M-k+j+1) break; sum+=vals[j]; sum-=vals[M-k+j]; if(sum<curOpt) { curOpt=sum; opt=j; } } vector<vector<int>> s(N,vector<int>(M,-1)); int cnt=0; for(int j=0;j<=opt;j++) { for(int i=0;i<N;i++) s[i][j]=cnt; cnt++; } for(int j=M-1;j>M-k+opt;j--) { for(int i=0;i<N;i++) s[i][j]=cnt; cnt++; } allocate_tickets(s); return curOpt; }
#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...