F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Round-table Conference

Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 475    Accepted Submission(s): 21


Problem Description
Round-table conferences were held around the round table, ensuring equal participations for leaders and attendants. It’s a custom holding the belief that “All men are created equal”, derived from the British story of King Arthur and his round table knights.
One day, Zero, as a sponsor holding a round-table conference, faces a tough problem. He knows that there are n groups of people (groups are labeled from 0 to n - 1) and m seats around the table (seats are labeled from 0 to m - 1) in the conference. There are ai people in the i-th group. They should be assigned seats within range (li, (li + 1)%m, (li+ 2)%m, . . . , ri).In a valid arrangment, everyone has a single seat, and no seat can be shared by more than one person. Zero wants to know whether such an arrangement exists.
 

Input
There are several test cases. Please process till EOF.
For each test case, The first line consists two numbers n(1 ≤ n ≤ 105) and m(1 ≤ m ≤ 109). Then follow n lines, each containing three numbers li, ri(0 ≤ li, ri< m) and ai(1 ≤ ai ≤ 109).
 

Output
For each test case, output a single line containing “Yes” if arrangement exists or “No” otherwise.
 

Sample Input
2 4 0 1 2 1 2 2 2 3 2 0 2 1 1 1
 

Sample Output
No Yes
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-20 13:02:22, Gzip enabled