제출 #838725

#제출 시각아이디문제언어결과실행 시간메모리
838725mychecksedad카니발 티켓 (IOI20_tickets)C++17
27 / 100
403 ms51376 KiB
#include<tickets.h> #include<bits/stdc++.h> using namespace std; #define ll long long int #define mod1 (1000000000+7) #define mod (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' const int N = 1e6+100, M = 1e5+10, K = 18; // void allocate_tickets( std::vector<std::vector<int>> _x); long long find_maximum(int k, vector<vector<int>> d){ ll ans = 0; int n = d.size(), m = d[0].size(); vector<vector<int>> A(n, vector<int>(m, -1)); vector<array<ll, 2>> a; set<array<int, 3>> big, small; vector<int> H(n), L(N); for(int i = 0; i < n; ++i){ H[i] = k; for(int j = m - k; j < m; ++j){ ans += d[i][j]; a.pb({-d[i][j]-d[i][j-(m-k)], i}); } } sort(all(a), greater<array<ll, 2>>()); for(int i = 0; i < n*k/2; ++i){ ans += a[i][0]; H[a[i][1]]--; } for(int i = 0; i < n; ++i) L[i] = k - H[i]; for(int i = 0; i < n; ++i){ if(H[i]) big.insert({-d[i][m - k], i, m - k}); if(L[i]) small.insert({-d[i][0], i, 0}); } for(int turn = 0; turn < k; ++turn){ vector<bool> used(n); set<array<int, 3>> bt, st; int c = 0; for(auto x: big){ if(used[x[1]] || c == n / 2){ bt.insert(x); continue; } used[x[1]] = 1; A[x[1]][x[2]] = turn; H[x[1]]--; c++; if(H[x[1]] > 0) bt.insert({d[x[1]][m - H[x[1]]], x[1], m - H[x[1]]}); } c = 0; for(auto x: small){ if(used[x[1]] || c == n / 2){ st.insert(x); continue; } used[x[1]] = 1; A[x[1]][x[2]] = turn; L[x[1]]--; c++; if(L[x[1]] > 0) st.insert({d[x[1]][L[x[1]]], x[1], L[x[1]]}); } big.swap(bt); small.swap(st); } allocate_tickets(A); 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...