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

Semafori

Silver IV 실버 IV
난이도
1s
시간 제한
32MB
메모리 제한
2
맞았습니다!!
4
제출 수
50.0%
정답률
레이팅

의견: 0

설명

Luka is driving his truck along a long straight road with many traffic lights. For each traffic light he knows how long the red and green lights will be on (the cycle repeating endlessly).

When Luka starts his journey, all traffic lights are red and just started their cycle. Luka moves one distance unit per second. When a traffic light is red, he stops and waits until it turns green.

Write a program that determines how much time Luka needs to reach the end of the road. The start of the road is at distance zero, the end at distance \(L\).

제약
입력 형식

The first line contains two integers \(N\) and \(L\) (\(1 \le N \le 100\), \(1 \le L \le 1000\)), the number of traffic lights on the road and the length of the road.

Each of the next \(N\) lines contains three integers \(D\), \(R\) and \(G\), describing one traffic light (\(1 \le D < L\), \(1 \le R \le 100\), \(1 \le G \le 100\)). \(D\) is the distance of the traffic light from the start of the road. \(R\) and \(G\) denote how long the red and green lights are on, respectively.

The traffic lights will be ordered in increasing order of \(D\). No two traffic lights will share the same position.

출력 형식

Output the time (in seconds) Luka needs to reach the end of the road.

서브태스크
서브태스크점수설명

Subtask 1

30점
예제 1
입력
2 10
3 5 5
5 2 2
출력
12
설명

Luka will wait 2 seconds at the first traffic light. After that he will reach the second traffic light while it is green and be able to pass through immediately.

예제 2
입력
4 30
7 13 5
14 4 4
15 3 10
25 1 1
출력
36
문제 정보

riseoj 작성

출처 COCI 2007/2008 Contest 6

평가 및 의견

Semafori

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

Log in to rate problems.

개별 의견

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

풀이 제출

Semafori

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