200642025-12-31 13:43:10szabelrMegrendelésekcpp17Accepted 50/5019ms784 KiB
// Megrendelések.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, k;
    cin >> n >> m >> k;
    vector<pair<int, int>> rendelesek(m + 1);
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        rendelesek[i] = { x,i };
    }
    sort(rendelesek.begin()+1, rendelesek.end());
    vector<pair<int, int>> res;
    int hol = 1;
    for (int i = 1; i <= n; i++)
    {
        while (hol <= m && rendelesek[hol].first < i)
        {
            hol++;
        }
        int maxdb = k;
        while (hol<=m and maxdb > 0 and i <= rendelesek[hol].first)
        {
            res.push_back({ rendelesek[hol].second,i });
            hol++;
            maxdb--;
        }
    }
    cout << res.size()<<endl;
    for (auto x : res)
        cout << x.first << " " << x.second << endl;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted17ms564 KiB
subtask25/5
3Accepted1ms316 KiB
4Accepted1ms508 KiB
5Accepted1ms316 KiB
6Accepted1ms316 KiB
7Accepted1ms316 KiB
subtask35/5
8Accepted1ms316 KiB
9Accepted1ms316 KiB
10Accepted2ms508 KiB
11Accepted2ms348 KiB
12Accepted2ms316 KiB
subtask45/5
13Accepted1ms316 KiB
14Accepted13ms644 KiB
15Accepted7ms316 KiB
16Accepted9ms596 KiB
17Accepted3ms316 KiB
subtask510/10
18Accepted2ms316 KiB
19Accepted2ms500 KiB
20Accepted3ms316 KiB
21Accepted3ms316 KiB
22Accepted2ms316 KiB
23Accepted1ms316 KiB
24Accepted3ms332 KiB
25Accepted4ms500 KiB
26Accepted4ms316 KiB
27Accepted4ms500 KiB
subtask625/25
28Accepted2ms316 KiB
29Accepted2ms500 KiB
30Accepted3ms316 KiB
31Accepted10ms564 KiB
32Accepted19ms760 KiB
33Accepted9ms564 KiB
34Accepted18ms744 KiB
35Accepted17ms768 KiB
36Accepted17ms784 KiB
37Accepted17ms772 KiB
38Accepted9ms588 KiB
39Accepted2ms316 KiB
40Accepted4ms316 KiB
41Accepted12ms564 KiB
42Accepted2ms500 KiB
43Accepted9ms508 KiB
44Accepted17ms744 KiB
45Accepted4ms440 KiB
46Accepted6ms316 KiB
47Accepted8ms564 KiB
48Accepted17ms756 KiB
49Accepted19ms780 KiB
50Accepted19ms760 KiB
51Accepted17ms564 KiB
52Accepted17ms768 KiB