제출 #1211701

#제출 시각아이디문제언어결과실행 시간메모리
1211701catch_me_if_you_canGift (IZhO18_nicegift)C++20
30 / 100
2102 ms251640 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)

const int MX = 2e5+5;
const int INF = 1e17;

signed main()
{
	fast();
	int n, k; cin >> n >> k;
	set<in> S;
	vector<vector<int>> op;
	for(int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		S.insert({x, i});
	}
	bool can = true;
	while(S.size())
	{
		if(S.size() < k)
		{
			can = false;
			break;
		}
		vector<in> readd;
		vector<int> stuff;
		for(int i = 1; i <= k; i++)
		{
			auto [X, g] = *prev(S.end());
			if(X >= 2)
				readd.pb({X-1, g});
			stuff.pb(g);
			S.erase(prev(S.end()));
		}
		op.pb(stuff);
		for(auto pp: readd)
			S.insert(pp);
	}
	if(!can)
	{
		cout << "-1\n";
		return 0;
	}
	cout << op.size() << "\n";
	for(auto v: op)
	{
		cout << "1 ";
		for(auto x: v)
			cout << x << " ";
		cout << "\n";
	}
	return 0;
}	
#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...