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

Go

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

의견: 0

설명

1 \(s / 512\) \(MB / 100\) points

Branimirko is still a passionate player of the wor\(ld-re\)nowned game Pokémon Go. Recently,

he decided to organize a competition in catching Pokémon. It will be held in Ilica street in

Zagreb, and the main sponsor is his friend Slavko. The reward is, of course, candy!

Ilica is, as we all know, the longest street in Zagreb. There are \(N\) houses on the same side of

the street, and each house has a house number between 1 and \(N\) . The competition begins

at house number \(K\) .

Before the competition, Branimirko looked at the map and saw \(M\) Pokémon. Each Pokémon

is located at its (distinct) house number \(A\) {i}{ }, is valued at \(B\) _{i} candy, and can be caught only in

the next \(T\) {i}{ } seconds, after which it disappears from the map and is impossible to catch.

Branimirko can visit one house number per second. Also, when he catches a Pokémon, that

Pokémon disappears from the map.

Since Branimirko really likes candy, he asked for your help.
Help him and determine the maximal amount of candy he can get!

제약

In test cases worth 20% of total points, it will hold \(M\) ≤ 10.
In additional 20% of total points, it will hold \(M\) ≤ 20.

1 \(s / 512\) \(MB / 100\) points

입력 형식

The first line of input contains integers N, \(K\) (1 ≤ \(K\)\(N \le 1\,000\)) and \(M\) (1 ≤ \(M \le 100\)), the

number of houses, the starting house number and the number of Pokémon.
Each of the following \(M\) lines contains integers \(A\) {i}{ }(1 ≤ \(A\) {i} ≤ \(N\) ), \(B\) (1 ≤ \(B\) {i} ≤100) and \(T\) ≤} (1 ≤ \(T\) _{i

2 000) from the task.
In the input data, the Pokémon will always be in a strictly ascending order by house number

\(A\) {i}{ }.

출력 형식

You must output the required maximal amount of candy from the task.

예제 1
입력
10 5 4
1 30 4
3 5 7
7 10 12
9 100 23

20 8 7
1 35 14
4 57 1
6 32 2
9 94 28
14 78 8
15 8 1
17 55 3
출력
output
115

172
설명

Clarification of the first test case:
One strategy is that Branimirko first catches the Pokémon at house number 3 (5 candy), then,

respectively, house numbers 7 (10 candy) and 9 (100 candy) for a total of 115 candy.
Notice that Branimirko can’t catch the Pokémon at house number 1, because he can’t reach it in time

from his starting position (house number 5).

문제 정보

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

출처 COCI 2017/2018 Contest 7

평가 및 의견

Go

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

Log in to rate problems.

개별 의견

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

풀이 제출

Go

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