제출 #928609

#제출 시각아이디문제언어결과실행 시간메모리
928609SUNWOOOOOOOO카니발 티켓 (IOI20_tickets)C++17
27 / 100
417 ms73284 KiB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pLL = array <LL, 2>;
using tLL = array <LL, 3>;

LL find_maximum(int k, vector<vector<int>> x) {
    LL ans = 0;
	int n = x.size(), m = x[0].size();
    vector <pLL> A;
    vector<vector<int>> s;
    s.resize(n, vector <int> (m, -1));
    priority_queue <tLL> pq;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            ans -= x[i][j];
            s[i][j] = j;
        }
    }
    for (int i = 0; i < n; i++) pq.push({x[i][k - 1] + x[i][m - 1], i, k - 1});
    for (int i = 0; i < n * k / 2; i++){
        tLL now = pq.top(); pq.pop();
        ans += now[0];
        s[now[1]][now[2]] = -1;
        s[now[1]][now[2] + m - k] = now[2];
        if (now[2]) pq.push({x[now[1]][now[2] - 1] + x[now[1]][now[2] + m - k - 1], now[1], now[2] - 1});
    }
    allocate_tickets(s);
    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...