제출 #417353

#제출 시각아이디문제언어결과실행 시간메모리
417353Aldas25카니발 티켓 (IOI20_tickets)C++14
100 / 100
789 ms60512 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define f first #define s second typedef long long ll; //int mxLeft[1600]; //int mxCnt[1600]; //int mnTaken[1600]; int mn[1600], mx[1600]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer; ll sum = 0; priority_queue<pair<ll, pair<int, int>>> q; for (int i = 0; i < n; i++) { std::vector<int> row(m); for (int j = 0; j < m; j++) { if (j >= m-k) { //row[j] = m-j-1; row[j] = -1; sum += x[i][j]; //mxLeft[i]++; //mxCnt[i]++; mx[i]++; } else { row[j] = -1; } } answer.push_back(row); q.push({- x[i][0] - x[i][m-k], {i, 0}}); } REP(n*k/2) { auto p = q.top(); q.pop(); ll val = p.f; int i = p.s.f; int j = p.s.s; sum += val; mx[i]--; mn[i]++; //mxLeft[i]--; //mxCnt[i]--; // answer[i][j] = k-j-1; // answer[i][m-k+j] = -1; if (j < k-1) { j++; q.push({- x[i][j] - x[i][m-k+j], {i,j}}); } } int mnId = 0; FOR(i, 0, n-1) { int cur = mnId; FOR(j, 0, mn[i]-1) { answer[i][j] = cur; cur = (cur+1)%k; } FOR(j, m-mx[i], m-1) { answer[i][j] = cur; cur = (cur+1)%k; } mnId = (mnId + mn[i]) % k; } allocate_tickets(answer); return sum; }
#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...