Submission #578753

#TimeUsernameProblemLanguageResultExecution timeMemory
5787532fat2codeCarnival Tickets (IOI20_tickets)C++17
11 / 100
2 ms724 KiB
#include "tickets.h" #include <bits/stdc++.h> #define fr first #define sc second #define all(s) s.begin(), s.end() using namespace std; const int nmax = 1505; int n, m, r[nmax]; long long ans; long long find_maximum(int k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); vector<pair<int,pair<int,int>>>arr; vector<vector<int>>lol(n, vector<int>(m)); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ arr.push_back({x[i][j], {i, j}}); } } sort(all(arr)); for(int i=0;i<(n*m/2);i++){ ans -= (long long)arr[i].fr; lol[arr[i].sc.fr][arr[i].sc.sc] = r[arr[i].sc.fr]++; } for(int i=(n*m/2);i<n*m;i++){ ans += (long long)arr[i].fr; lol[arr[i].sc.fr][arr[i].sc.sc] = r[arr[i].sc.fr]++; } allocate_tickets(lol); 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...