제출 #301854

#제출 시각아이디문제언어결과실행 시간메모리
301854majk카니발 티켓 (IOI20_tickets)C++17
0 / 100
1 ms256 KiB
#include <vector> #include <algorithm> #include "tickets.h" using namespace std; #define x first #define y second typedef std::pair<int,int> pii; typedef long long ll; template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}}; ll find_maximum(int K, vector<vector<int>> A) { int N = A.size(), M = A[0].size(); ll tot = 0; vector<pii> S; for (int i = 0; i < N; ++i) { for (int j = 0; j < K; ++j) { tot += A[i][j+M-K]; S.push_back({A[i][j] + A[i][j+M-K], i}); } } nth_element(S.begin(), S.begin() + N*K/2, S.end()); vector<int> CntLo(N, 0), CntHi(N); for (int i = 0; i < N*K/2; ++i) { tot -= S[i].x; CntLo[S[i].y]++; } for (int i = 0; i < N; ++i) CntHi[i] = K - CntLo[i]; vector2<int> T(N, M, -1); for (int i = 0; i < K; ++i) { int lo = N/2, hi = N/2; for (int j = 0; j < N; ++j) { hi -= CntLo[j] == 0; lo -= CntHi[j] == 0; } for (int j = 0; j < N; ++j) { if (CntLo[j] == 0 || lo == 0) { T[j][M-CntHi[j]] = i; hi -= (CntLo[j] != 0); --CntHi[j]; } else { --CntLo[j]; T[j][CntLo[j]] = i; lo -= (CntHi[j] != 0); } } } allocate_tickets(T); return tot; }
#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...