Submission #1291710

#TimeUsernameProblemLanguageResultExecution timeMemory
1291710ChuanChenCarnival Tickets (IOI20_tickets)C++20
14 / 100
250 ms53340 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1505; int n, m, cnt0[MAXN], cnt1[MAXN]; vector<vector<int>> ans; ll total_prize; bool cmp(int a, int b){ return cnt0[a] < cnt0[b]; } long long find_maximum(int k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); ans.assign(n, vector<int>(m, -1)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if(x[i][j] == 0) cnt0[i]++; else cnt1[i]++; } } for(int r = 0; r < k; r++){ vector<int> escolhe1, escolhe0, nescolheu; for(int i = 0; i < n; i++){ if(cnt0[i] == 0)//preciso pegar 1 escolhe1.push_back(i); else if(cnt1[i] == 0)//preciso pegar 0 escolhe0.push_back(i); else nescolheu.push_back(i); } sort(nescolheu.begin(), nescolheu.end(), cmp); //quem tem mais 0 doa 0, mais 1 doa 1 for(int e : nescolheu){//da frente eh que tem menos zero if((int)escolhe1.size() < n/2) escolhe1.push_back(e); else escolhe0.push_back(e); } for(int e : escolhe0){ cnt0[e]--; ans[e][cnt0[e]] = r; } for(int e : escolhe1){ ans[e][m-cnt1[e]] = r; cnt1[e]--; } total_prize += min(escolhe0.size(), escolhe1.size()); } allocate_tickets(ans); return total_prize; }
#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...