#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';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
1008 KB |
n=8 |
9 |
Correct |
5 ms |
620 KB |
n=14 |
10 |
Correct |
3 ms |
620 KB |
n=11 |
11 |
Correct |
19 ms |
1520 KB |
n=50000 |
12 |
Correct |
18 ms |
1536 KB |
n=50000 |
13 |
Correct |
17 ms |
1260 KB |
n=10 |
14 |
Correct |
18 ms |
1260 KB |
n=685 |
15 |
Correct |
17 ms |
1260 KB |
n=623 |
16 |
Correct |
10 ms |
880 KB |
n=973 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
1008 KB |
n=8 |
9 |
Correct |
5 ms |
620 KB |
n=14 |
10 |
Correct |
3 ms |
620 KB |
n=11 |
11 |
Correct |
19 ms |
1520 KB |
n=50000 |
12 |
Correct |
18 ms |
1536 KB |
n=50000 |
13 |
Correct |
17 ms |
1260 KB |
n=10 |
14 |
Correct |
18 ms |
1260 KB |
n=685 |
15 |
Correct |
17 ms |
1260 KB |
n=623 |
16 |
Correct |
10 ms |
880 KB |
n=973 |
17 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
638 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
1008 KB |
n=8 |
9 |
Correct |
5 ms |
620 KB |
n=14 |
10 |
Correct |
3 ms |
620 KB |
n=11 |
11 |
Correct |
19 ms |
1520 KB |
n=50000 |
12 |
Correct |
18 ms |
1536 KB |
n=50000 |
13 |
Correct |
17 ms |
1260 KB |
n=10 |
14 |
Correct |
18 ms |
1260 KB |
n=685 |
15 |
Correct |
17 ms |
1260 KB |
n=623 |
16 |
Correct |
10 ms |
880 KB |
n=973 |
17 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
18 |
Halted |
0 ms |
0 KB |
- |