Submission #378704

#TimeUsernameProblemLanguageResultExecution timeMemory
378704cheissmartGift (IZhO18_nicegift)C++14
18 / 100
638 ms524292 KiB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	if(k == 2) {
		int mx = 0;
		vi aux;
		for(int i = 0; i < n; i++) {
			int a;
			cin >> a;
			for(int j = 0; j < a; j++)
				aux.PB(i);
			mx = max(mx, a);
		}
		if(aux.size() % 2 == 1 || mx * 2 > int(aux.size())) {
			cout << -1 << '\n';
			return 0;
		}
		int m = aux.size();
		cout << m / 2 << '\n';
		for(int i = 0; i < m / 2; i++) {
			cout << 1 << ' ' << aux[i] + 1 << ' ' << aux[i + m / 2] + 1 << '\n';
		}
	}
	
}

#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...