Submission #705832

#TimeUsernameProblemLanguageResultExecution timeMemory
705832finn__카니발 티켓 (IOI20_tickets)C++17
27 / 100
481 ms54812 KiB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;

long long find_maximum(int k, vector<vector<int>> x)
{
    long long value = 0;
    for (size_t i = 0; i < x.size(); i++)
        for (size_t j = 0; j < k; j++)
            value -= x[i][j];

    vector<size_t> y(x.size(), k);
    priority_queue<pair<int64_t, size_t>> q;
    for (size_t i = 0; i < x.size(); i++)
        q.emplace(x[i][k - 1] + x[i].back(), i);

    for (size_t z = 0; z < x.size() * k / 2; z++)
    {
        auto const [d, i] = q.top();
        q.pop();
        value += d;
        y[i]--;
        if (y[i])
            q.emplace(x[i][y[i] - 1] + x[i][x[i].size() - (k - y[i] + 1)], i);
    }

    vector<vector<int>> a(x.size(), vector<int>(x[0].size(), -1));
    vector<size_t> assigned_low(k, 0);

    for (size_t i = 0; i < x.size(); i++)
    {
        size_t low = y[i], up = k - y[i];
        for (size_t j = 0; j < k; j++)
        {
            if (assigned_low[j] < x.size() / 2 && low)
                a[i][--low] = j, assigned_low[j]++;
            else
                a[i][x[i].size() - up--] = j;
        }
    }

    allocate_tickets(a);
    return value;
}

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:9:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |         for (size_t j = 0; j < k; j++)
      |                            ~~^~~
tickets.cpp:33:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         for (size_t j = 0; j < k; j++)
      |                            ~~^~~
#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...