RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0501

Drought

Gold II 골드 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

The grass has dried up in Farmer John's pasture due to a drought. After hours of
despair and contemplation, FJ comes up with the brilliant idea of purchasing
corn to feed his precious cows.

FJ’s \(N\) (\(1 \leq N \leq 100\)) cows are arranged in a line such that the \(i\)th
cow in line has a non-negative integer hunger level of \(h_i\). As FJ’s cows are
social animals and insist on eating together, the only way FJ can decrease the
hunger levels of his cows is to select two adjacent cows \(i\) and \(i+1\) and feed
each of them a bag of corn, causing each of their hunger levels to decrease by
one.

FJ wants to feed his cows until all of them have the same non-negative hunger
level. Although he doesn't know his cows' exact hunger levels, he
does know an upper bound on the hunger level of each cow; specifically, the
hunger level \(h_i\) of the \(i\)-th cow is at most \(H_i\) (\(0\le H_i\le 1000\)).

Your job is to count the number of \(N\)-tuples of hunger levels
\([h_1,h_2,\ldots,h_N]\) that are consistent with these upper bounds such that it
is possible for FJ to achieve his goal, modulo \(10^9+7\).

Problem credits: Arpan Banerjee and Benjamin Qi

제약

SCORING

\(N\) is even in even-numbered tests and odd in odd-numbered tests.

  • Tests 3 and 4 satisfy \(N\le 6\) and \(H_i \le 10\).
  • Tests 5 through 10 satisfy \(N\le 50\) and \(H_i \le 100\).
  • Tests 11 through 20 satisfy no further constraints.

Problem credits: Arpan Banerjee and Benjamin Qi

입력 형식

The first line contains \(N\).

The second line contains \(H_1,H_2,\ldots,H_N\).

출력 형식

The number of \(N\)-tuples of hunger levels modulo \(10^9+7\).

예제 1
입력
3
9 11 7
출력
241
설명

There are \((9+1)\cdot (11+1)\cdot (7+1)\) \(3\)-tuples \(h\) that are consistent with
\(H\).

One of these tuples is \(h=[8,10,5]\). In this case, it is possible to make all
cows have equal hunger values: give two bags of corn to both cows \(2\) and \(3\),
then give five bags of corn to both cows \(1\) and \(2\), resulting in each cow
having a hunger level of \(3\).

Another one of these tuples is \(h=[0,1,0]\). In this case, it is impossible to
make the hunger levels of the cows equal.

예제 2
입력
4
6 8 5 9
출력
137
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2021-2022 > January > Gold

태그

평가 및 의견

Drought

개요
출제자 난이도 Gold II 골드 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Drought

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8