Logo
(追記) (追記ここまで)

8088번 - Airports 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB59292244.000%

문제

There are n towns with their own airports in the country X. We know the maximal capacities of the airports — the airport in the town Mi can have at most di connections with other towns. The task is to design the net of air connections among the towns in such a way that the town Mi has exactly di connections with other towns. We assume that connections are two-way and that each pair of towns has at most one connection between them.

Write a program that:

  • reads the number of towns n and the numbers di from the standard input,
  • designs the net of air connections in such a way that for every i, 1 ≤ i ≤ n, the town Mi has exactly di connections with other towns,
  • writes the list of all connections to the standard output.

We assume that for the given data a solution exists. If there exists more than one solution the program should find only one. It can happen that there is no connection (even indirect) between a pair of cities.

입력

In the first line of the standard input there is written one integer n, 3 ≤ n ≤ 500, which is the number of towns. In the following n lines there are written positive integers di (one integer in each line).

출력

Your program should write all the connections of the created net to the standard output. The description of each connection consists of two positive integers separated by a single space. These integers are the numbers of two connected towns. Each description should be placed in a separate line. The numbers of towns in a line can be written in an arbitrary order. Similarly, the order of connections is not important.

제한

예제 입력 1

6
2
3
2
4
1
2

예제 출력 1

4 2
4 1
4 3
4 6
2 5
2 1
3 6

힌트

출처

Olympiad > Polish Olympiad in Informatics > POI 1996/1997 > Stage 2 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /