32292023-02-22 22:27:11TuruTamasÜgyfélszolgálat (45)cpp17Wrong answer 14/45137ms10612 KiB
#include <bits/stdc++.h>
#include <functional>
#include <map>
#include <queue>
#include <vector>

using namespace std;

#define pii pair<long, long>

struct comp {
    bool operator()(pii a, pii b) {
        if (a.first < b.first) return false;
        if (b.first < a.first) return true;
        return false;
    }
};

long lines_read = 0;
long N, M;
vector<long> pultok;
queue<pii> q;

pii next() {
    if (q.empty()) {
        pii r;
        cin >> r.first >> r.second;
        lines_read++;
        return r;
    }
    pii r = q.front();
    q.pop();
    return r;
}
long count(long t) {
    if (lines_read == N) return q.size();
    pii x;
    cin >> x.first >> x.second;
    lines_read++;
    q.push(x);
    while (x.first < t && lines_read < N)
    {
        cin >> x.first >> x.second;
        lines_read++;
        q.push(x);
    }
    return q.size();
}
int  main() {
    cin >> M >> N;
    priority_queue<pii, vector<pii>, comp> pq;
    priority_queue<long, vector<long>, greater<long>> pq2;
    for (size_t i = 1; i < M+1; i++)
    {
        pq.push({0, i});
    }
    long E, H;
    long maxvarido = 0;
    long maxvarakozo = 0;
    for (size_t i = 0; i < N; i++)
    {
        pii temp = next();
        E = temp.first;
        H = temp.second;
        while (pq.top().first <= E && !pq.empty()) {
            pq2.push(pq.top().second);
            pq.pop();
        }
        if (pq2.empty()) {
            long elso = pq.top().first;
            maxvarido = max(maxvarido, elso-E);
            maxvarakozo = max(count(elso), maxvarakozo);
            while (pq.top().first == elso && !pq.empty()) {
                pq2.push(pq.top().second);
                pq.pop();
            }
            pq.push({elso+H, pq2.top()});
            // cout << i << " " << pq2.top() << endl;
            pultok.push_back(pq2.top());
            pq2.pop();
        }
        else {
            pq.push({E+H, pq2.top()});
            // cout << i << " " << pq2.top() << endl;
            pultok.push_back(pq2.top());
            pq2.pop();
        }
        
    }
    while (pq.size() > 1) pq.pop();
    cout << pq.top().first << " " << maxvarido << " " << maxvarakozo << "\n";
    for (long& x : pultok) {
        cout << x << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base14/45
1Accepted0/03ms1812 KiB
2Accepted0/057ms4248 KiB
3Accepted2/23ms2240 KiB
4Wrong answer0/24ms2504 KiB
5Wrong answer0/23ms2720 KiB
6Wrong answer0/23ms2752 KiB
7Wrong answer0/23ms2888 KiB
8Wrong answer0/293ms8884 KiB
9Wrong answer0/282ms9844 KiB
10Partially correct1/2112ms9172 KiB
11Wrong answer0/285ms9128 KiB
12Wrong answer0/285ms9124 KiB
13Wrong answer0/2103ms10204 KiB
14Wrong answer0/293ms9376 KiB
15Wrong answer0/294ms10152 KiB
16Wrong answer0/287ms10496 KiB
17Wrong answer0/297ms10544 KiB
18Wrong answer0/296ms10612 KiB
19Accepted2/2137ms10032 KiB
20Accepted3/3137ms10028 KiB
21Partially correct2/4112ms9920 KiB
22Accepted4/4112ms10040 KiB