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

10416번 - Restaurant Ratings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB32232180.769%

문제

A famous travel web site has designed a new restaurant rating system. Each restaurant is rated by one of n (1 ≤ n ≤ 15) critics, each giving the restaurant a nonnegative numeric rating (higher score means better). Some of these critics are more influential than others.

The restaurants in each city are ranked as follows. First, sum up the ratings given by all the critics for a restaurant. A restaurant with a higher total sum is always better than one with a lower total sum. For restaurants with the same total sum, we rank them based on the ratings given by critic 1. If there is a tie, then we break ties by the ratings by critic 2, etc.

A restaurant owner received the ratings for his restaurant, and is curious about how it ranks in the city. He does not know the ratings of all the other restaurants in the city, so he would estimate this by computing the maximum number of different ratings that is no better than the one received by the restaurant. You are asked to write a program to answer his question.

입력

The input consists of a number of cases. Each case is specified on one line. On each line, the first integer is n, followed by n integers containing the ratings given by the n critics (in order). You may assume that the total sum of ratings for each restaurant is at most 30. The input is terminated by a line containing n = 0.

출력

For each input, print the number of different ratings that is no better than the given rating. You may assume that the output fits in a 64-bit signed integer.

제한

예제 입력 1

1 3
2 4 3
5 4 3 2 1 4
0

예제 출력 1

4
33
10810

힌트

출처

ICPC > Regionals > North America > Rocky Mountain Regional > 2014 Rocky Mountain Regional Contest H번

ICPC > Regionals > North America > North Central North America Regional > NCNA 2014 F번

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

출처

대학교 대회

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

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