제출 #838706

#제출 시각아이디문제언어결과실행 시간메모리
838706mychecksedad카니발 티켓 (IOI20_tickets)C++17
27 / 100
406 ms73112 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<int, 2>> a; vector<array<int, 3>> big, small; vector<int> H(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<int, 2>>()); int c = 0; for(int i = 0; i < n*k/2; ++i, ++c){ if(H[a[c][1]] == 0){ --i; continue; } ans += a[c][0]; H[a[c][1]]--; } for(int i = 0; i < n; ++i){ for(int j = m - 1; j >= m - H[i]; --j){ big.pb({d[i][j], i, j}); } for(int j = 0; j < k - H[i]; ++j){ small.pb({d[i][j], i, j}); } } sort(all(big)); sort(all(small)); for(int turn = 0; turn < k; ++turn){ for(int j = turn * (n / 2); j < turn * (n / 2) + n / 2; ++j){ A[big[j][1]][big[j][2]] = turn; A[small[j][1]][small[j][2]] = turn; } } 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...