-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLastManStanding.java
More file actions
41 lines (34 loc) · 951 Bytes
/
LastManStanding.java
File metadata and controls
41 lines (34 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class LastManStanding {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(in.readLine());
StringTokenizer s = new StringTokenizer(in.readLine());
int[] scores = new int[n];
long total = 0;
for (int i = 0; i < n; i++) {
scores[i] = Integer.parseInt(s.nextToken());
total += scores[i];
}
if(total >= n) {
out.println("NO");
}
else {
out.println("YES");
int last = n - 1;
for (int i = n - 1; i >= 0; i--) {
for (int j = 0; j < scores[i]; j++) {
out.println((i + 1) + " " + (last + 1));
last--;
}
}
}
out.flush();
out.close();
}
}