Submission #1047769

#TimeUsernameProblemLanguageResultExecution timeMemory
1047769idasCarnival Tickets (IOI20_tickets)C++17
11 / 100
1 ms860 KiB
#include "tickets.h" #include "bits/stdc++.h" #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) #define le(x) ((x)[((int)(x).size())-1]) #define sz(x) ((int)((x).size())) #define pb push_back #define s second #define f first using namespace std; typedef long long ll; typedef vector<int> vi; const int MxN=1510, INF=1e9; int n, m; long long find_maximum(int k, std::vector<std::vector<int>> x) { n=sz(x); m=sz(x[0]); ll ret=0; vector s(n, vector(m,-1)); vector<pair<vector<int>,int>> vec; FOR(i, 0, n) { vi now; FOR(j, 0, m) { now.pb(x[i][j]); } vec.pb({now,i}); } sort(vec.begin(), vec.end()); vi now; FOR(i, 0, n/2) { int in1=vec[i].s, in2=vec[n-1-i].s; int val1=x[in1][0], val2=x[in2][m-1]; s[in1][0]=s[in2][m-1]=0; now.pb(val1); now.pb(val2); } sort(now.begin(), now.end()); int md=now[sz(now)/2]; for(auto it : now) { ret+=abs(it-md); } allocate_tickets(s); return ret; } /* 2 3 2 0 2 5 1 1 3 4 2 1 5 9 1 4 3 6 2 7 4 4 1 0 1 2 9 4 4 4 5 3 3 3 7 3 4 4 4 4 2 1 0 10 1 5 0 6 0 6 4 4 1 0 1 2 9 7 7 7 7 7 7 7 7 7 7 7 7 8 2 1 1 9 0 10 2 3 3 4 6 8 1 5 0 2 3 4 4 3 2 0 1 1 1 1 1 0 0 1 0 0 0 4 2 2 0 1 0 1 0 0 1 1 4 2 1 0 1 0 0 0 0 1 1 */
#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...