65 lines
1.3 KiB
Java
65 lines
1.3 KiB
Java
package chelper;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
import io.InputReader;
|
|
import io.OutputWriter;
|
|
|
|
public class B {
|
|
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
|
int n = in.nextInt();
|
|
int pol = in.nextInt();
|
|
if (pol == 0) {
|
|
out.print(-1);
|
|
return;
|
|
}
|
|
|
|
List<Chelik> cheliki = new ArrayList<>();
|
|
for (int i = 2; i <= n; i++) {
|
|
cheliki.add(new Chelik(i, in.nextInt()));
|
|
}
|
|
Collections.sort(cheliki);
|
|
cheliki.add(0, new Chelik(1, pol));
|
|
|
|
List<String> answer = new ArrayList<>();
|
|
|
|
int left = 0;
|
|
for (int right = 1; right < n; right++) {
|
|
if (left == right) {
|
|
out.print(-1);
|
|
return;
|
|
}
|
|
if (cheliki.get(left).dzun > 0) {
|
|
answer.add(cheliki.get(left).index + " " + cheliki.get(right).index);
|
|
cheliki.get(left).dzun--;
|
|
} else {
|
|
left++;
|
|
right--;
|
|
}
|
|
}
|
|
|
|
out.println(answer.size());
|
|
for (String s : answer) {
|
|
out.println(s);
|
|
}
|
|
}
|
|
|
|
class Chelik implements Comparable<Chelik> {
|
|
int index;
|
|
int dzun;
|
|
|
|
public Chelik(int index, int dzun) {
|
|
this.index = index;
|
|
this.dzun = dzun;
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Chelik o) {
|
|
return Integer.compare(o.dzun, dzun);
|
|
}
|
|
}
|
|
}
|