제출 #1047776

#제출 시각아이디문제언어결과실행 시간메모리
1047776idas카니발 티켓 (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, l[MxN], ri[MxN]; long long find_maximum(int k, std::vector<std::vector<int>> x) { n=sz(x); m=sz(x[0]); FOR(i, 0, n) ri[i]=m-1; 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(r, 0, k) FOR(i, 0, n/2) { int in1=vec[i].s, in2=vec[n-1-i].s; int val1=x[in1][l[in1]], val2=x[in2][ri[in2]]; s[in1][l[in1]++]=s[in2][ri[in2]--]=r; 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...