아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Magic Potions

시간 제한2초메모리 제한1024 MB

요약
두 물질로 만드는 물약의 총 개수를 최대로 만들고, 동점일 때 (1,2), (1,3), ... 순서의 쌍을 우선해 각 쌍의 개수를 출력한다.
난이도

보통10점 중 7점

유형
그리디, 정렬
정답자
아직 제출이 없습니다

문제

L'Ashyto is a famous magician. He is working in his laboratory on a new set of magic potions to sell on the upcoming magic fair. He has bought several bottles of each of nn different magic substances that can be used to create magic potions. Each magic potion must be composed of two different magic substances. To create a potion the magician mixes the contains of two bottles and pronounces the magic spell.

The price of a potion is proportional to the quality of the ingredients: the better substances are used --- the more expensive the potion is. Of course, L'Ashyto would like to create as expensive potions as possible. On the other side, differences in prices are not as significant as the prices themselves. Therefore the first priority is the number of potions.

L'Ashyto has numbered all substances from 1 to nn, substance number 1 being the best, and substance number nn being the worst. He would like to create as many potions as possible. If there are several ways to do so, he would like to create as many potions from substances 1 and 2, as possible. If there are still several variants, he would like to maximize the number of 1+31+3 potions, then 1+41+4 potions, etc, 1+n1+n potions, 2+32+3 potions, etc. Help him to find out how many potions of which ingredients to create.

입력

The first line of the input file contains nn --- the number of substances L'Ashyto has (2≤n≤100,0002 \le n \le 100\\,000). The second line contains nn integer numbers: a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n --- the number of bottles of the first substance, the number of bottles of the second substance, etc (1≤a_i≤1091 \le a\_i \le 10^9).

출력

The first line of the output file must contain mm --- the number of different types of potions L'Ashyto must create. The following mm lines must contain three integer numbers each: i,j,c_iji, j, c\_{ij} --- the numbers of substances to create a potion of, and how many such potions to create. For each description there must be i<ji < j. Output potion description in order of decreasing their price.

예제1

  1. 예제 1

    입력
    4
    1 1 1 1
    
    예상 출력
    2
    1 2 1
    3 4 1