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

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

Melons

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

요약
각 시작 위치 x에 대해 무게 합이 L을 넘지 않도록 멜론을 순서대로 상자에 담을 때, 상자 개수와 마지막 상자의 무게를 구한다.
난이도

보통10점 중 7점

유형
배열, 누적 합, 이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

In EGOI Farm, the employees are receiving and shipping melons. This morning, NN melons are received. The melons are numbered from 11 to NN. The weight of melon ii (1≤i≤N1 ≤ i ≤ N) is A_iA\_i.

Rie is working at EGOI Farm. Her job is packing melons into boxes. Now, an integer xx (1≤x≤N1 ≤ x ≤ N) is determined in EGOI Farm. After that, she will receive the melons x,x+1,…,Nx, x + 1, \dots , N, in this order. She will pack them into boxes by repeating the following process.

  • Rie will take an empty box. She will repeat putting the melons into the box. However, if the total weight of the melons in the box will exceeds LL after putting the next melon into the box, she will not put it into the box. Then, she will ship the box. (In this case, she will put the next melon into a new box.)

After putting the melon NN into a box, she will ship the box, and her job will be finished.

Rie wants to prepare for her job for all possible values of xx. Write a program which, given information of the melons and the maximum possible weight LL of a box, calculates the number of boxes shipped by her and the total weight of the melons in the last box for all possible values of xx.

입력

Read the following data from the standard input. Given values are all integers.

NN LL

A_1A\_1

A_2A\_2

⋮\vdots

A_NA\_N

출력

Write NN lines to the standard output. The ii-th line (1≤i≤N1 ≤ i ≤ N) of output corresponds to the case x=ix = i. This line should contain the number of shipped boxes and the total weight of the melons in the last box if x=ix = i. These two values should be separated by a space.

제한

  • 1≤N≤200,0001 ≤ N ≤ 200\\,000.
  • 1≤L≤1,000,000,000(=109)1 ≤ L ≤ 1\\,000\\,000\\,000 (= 10^9).
  • 1≤A_i≤L1 ≤ A\_i ≤ L (1≤i≤N1 ≤ i ≤ N).

예제3

  1. 예제 1

    입력
    7 100
    20
    80
    50
    40
    20
    80
    10
    
    예상 출력
    4 10
    4 10
    3 10
    2 90
    2 10
    1 90
    1 10
    
  2. 예제 2

    입력
    6 160
    63
    63
    63
    63
    63
    63
    
    예상 출력
    3 126
    3 63
    2 126
    2 63
    1 126
    1 63
    
  3. 예제 3

    입력
    5 20
    7
    10
    4
    6
    8
    
    예상 출력
    2 18
    2 8
    1 18
    1 14
    1 8