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

S3. Lunch Concert

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

It’s lunchtime at your school! Your \(N\) friends are all standing on a long
field, as they usually do. The field can be represented as a number
line, with the \(i\)th friend initially
at position \(P_i\) metres along it.
The \(i\)th friend is able to walk in
either direction along the field at a rate of one metre per \(W_i\) seconds, and their hearing is good
enough to be able to hear music up to and including \(D_i\) metres away from their position.
Multiple students may occupy the same positions on the field, both
initially and after walking.

You’re going to hold a little concert at some position \(c\) metres along the field (where \(c\) is any integer of your choice), and
text all of your friends about it. Once you do, each of them will walk
along the field for the minimum amount of time such that they end up
being able to hear your concert (in other words, such that each friend
\(i\) ends up within \(D_i\) units of \(c\)).

You’d like to choose \(c\) such that
you minimize the sum of all \(N\) of
your friends’ walking times. What is this minimum sum (in seconds)?
Please note that the result might not fit within a 32-bit integer.

제약

\((1 \le i \le N)\)

Marks

The following table shows how the available 15 marks are
distributed.

4 marks \(1 \le N \le 2000\) \(0 \le P_i \le 2000\) \(1 \le W_i \le 1000\) \(0 \le D_i \le 2000\)
9 marks \(1 \le N \leq 200\,000\) \(0 \le P_i \le 1\,000\,000\)
2 marks \(1 \le N \leq 200\,000\) \(0 \le P_i \leq 1\,000\,000\ 000\)
입력 형식

The first line of input contains \(N\).

The next \(N\) lines contain three
space-separated integers, \(P_i\),
\(W_i\), and \(D_i\) \((1 \le i \le N)\).

출력 형식

Output one integer which is the minimum possible sum of walking times
(in seconds) for all \(N\) of your
friends to be able to hear your concert.

예제 1
입력
1
0 1000 0
출력
0
설명

If you choose \(c = 0\), your single
friend won’t need to walk at all to hear it.

예제 2
입력
2
10 4 3
20 4 2
출력
20
설명

One possible optimal choice of \(c\) is
\(14\), which would require your first
friend to walk to position \(11\)
(taking \(4 \times 1 = 4\) seconds) and
your second friend to walk to position \(16\) (taking \(4 \times 4 = 16\) seconds), for a total of \(20\) seconds.

예제 3
입력
3
6 8 3
1 4 1
14 5 2
출력
43
문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2021 Senior

평가 및 의견

S3. Lunch Concert

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

S3. Lunch Concert

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