248142026-02-15 20:18:17ProgramozoRokaMegrendelésekcpp17Accepted 50/504ms804 KiB
#include <iostream>
#include <vector>
#include<algorithm>
#include <cstdio>

using namespace std;
inline int r() {
	int x = 0;
	char c = getchar(); // Windows-on getchar(), Linux-on getchar_unlocked() még gyorsabb

	while (c < '0' || c > '9') {
		c = getchar();
	}

	while (c >= '0' && c <= '9') {
		x = (x << 3) + (x << 1) + (c - '0');
		c = getchar();
	}
	return x;
}

struct tomb
{
	int a;
	int b;
};
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, m, k;
	n = r(); m = r(); k = r();
	tomb x;
	vector<tomb> t;
	vector<tomb> meg;
	for (int i = 0; i < m; ++i)
	{
		x.b = r();
		x.a = i + 1;
		t.push_back(x);
	}
	sort(t.begin(), t.end(), [](const tomb& g, const tomb& h) { return g.b < h.b; });
	int szam = 0;
	for (int nap = 1; nap <= n; ++nap)
	{
		for (int i = 0; i < k and szam < m; ++i)
		{
			if (t[szam].b >= nap)
			{
				t[szam].b = nap;
				meg.push_back(t[szam]);
				++szam;
			}
			else
			{
				while (!(t[szam].b >= nap) and szam < m) ++szam;
				if (szam < m)
				{
					t[szam].b = nap;
					meg.push_back(t[szam]);
					++szam;
				}
			}
		}
	}
	printf("%d\n", (int)meg.size());
	for (const auto& m : meg) {
		printf("%d %d\n", m.a, m.b);
	}
	return 0;
}


SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted4ms728 KiB
subtask25/5
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Accepted1ms316 KiB
6Accepted1ms316 KiB
7Accepted1ms316 KiB
subtask35/5
8Accepted2ms316 KiB
9Accepted2ms316 KiB
10Accepted2ms316 KiB
11Accepted2ms316 KiB
12Accepted1ms316 KiB
subtask45/5
13Accepted1ms316 KiB
14Accepted3ms564 KiB
15Accepted2ms356 KiB
16Accepted2ms564 KiB
17Accepted2ms508 KiB
subtask510/10
18Accepted1ms316 KiB
19Accepted1ms316 KiB
20Accepted1ms316 KiB
21Accepted1ms384 KiB
22Accepted2ms316 KiB
23Accepted2ms316 KiB
24Accepted2ms508 KiB
25Accepted3ms564 KiB
26Accepted2ms564 KiB
27Accepted2ms564 KiB
subtask625/25
28Accepted1ms324 KiB
29Accepted1ms316 KiB
30Accepted1ms316 KiB
31Accepted3ms748 KiB
32Accepted4ms564 KiB
33Accepted3ms564 KiB
34Accepted4ms564 KiB
35Accepted4ms600 KiB
36Accepted4ms568 KiB
37Accepted4ms636 KiB
38Accepted2ms564 KiB
39Accepted1ms532 KiB
40Accepted2ms316 KiB
41Accepted4ms564 KiB
42Accepted2ms508 KiB
43Accepted2ms564 KiB
44Accepted4ms564 KiB
45Accepted1ms472 KiB
46Accepted2ms316 KiB
47Accepted2ms532 KiB
48Accepted4ms780 KiB
49Accepted4ms804 KiB
50Accepted4ms564 KiB
51Accepted4ms564 KiB
52Accepted4ms772 KiB