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

Range Reconstruction

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

의견: 0

설명

Bessie has an array \(a_1, \ldots, a_N\), where \(1 \leq N \leq 300\) and
\(0 \leq a_i \leq 10^9\) for all \(i\). She won't tell you \(a\) itself, but she will
tell you the range of each subarray of \(a\). That is, for each pair of indices
\(i \leq j\), Bessie tells you \(r_{i, j} = \max a[i\ldots j] - \min a[i\ldots j]\).
Given these values of \(r\), please construct an array that could have been
Bessie's original array. The values in your array should be in the range
\([-10^9, 10^9]\).

Problem credits: Danny Mittal

제약

SCORING

  • Test 5 satisfies \(r_{1,N} \leq 1\).
  • Tests 6-8 satisfy \(r_{i,i+1} = 1\) for all \(1 \leq i < N\).
  • Tests 9-14 satisfy no additional constraints.

Problem credits: Danny Mittal

입력 형식

The first line contains \(N\).

Another \(N\) lines follow. The \(i\)th of these lines contains the integers
\(r_{i, i}, r_{i, i + 1}, \ldots, r_{i, N}\).

It is guaranteed that there is some array \(a\) with values in the range
\([0, 10^9]\) such that for all \(i \leq j\),
\(r_{i, j} = \max a[i\ldots j] - \min a[i\ldots j]\).

출력 형식

Output one line containing \(N\) integers \(b_1, b_2, \ldots, b_N\) in the range
\([-10^9, 10^9]\) representing your array. They must satisfy
\(r_{i, j} = \max b[i\ldots j] - \min b[i\ldots j]\) for all \(i \leq j\).

예제 1
입력
3
0 2 2
0 1
0
출력
1 3 2
설명

For example, \(r_{1, 3} = \max a[1\ldots 3] - \min a[1\ldots 3] = 3 - 1 = 2\).

예제 2
입력
3
0 1 1
0 0
0
출력
0 1 1
설명

This example satisfies the constraints for subtask 1.

예제 3
입력
4
0 1 2 2
0 1 1
0 1
0
출력
1 2 3 2
설명

This example satisfies the constraints for subtask 2.

예제 4
입력
4
0 1 1 2
0 0 2
0 2
0
출력
1 2 2 0
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2022-2023 > December > Silver

태그

평가 및 의견

Range Reconstruction

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

Log in to rate problems.

개별 의견

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

풀이 제출

Range Reconstruction

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