Submission #71318552
Source Code Expand
'''
方針:
1: 各目標について以下を試す
1-1: 現在存在しうる高さH_low[i], H_high[i]から時刻tiで到達可能な高さのH_low[i+1], H_hig[i+1]を求める
1-2: u < H_low[i+1] or H_hig[i+1] < l ならその目標は達成不可能 そうでないなら可能
'''
from collections import defaultdict
def check_available():
N,H = list(map(int, input().split()))
is_available = True
now_t = 0
low, high = H,H # 現時点の高さの下限, 上限
for i in range(N):
t,l,u = list(map(int, input().split()))
elapsed_t = t - now_t # 経過時間
low_next, high_next = max(low-elapsed_t,0), high+elapsed_t # WAの理由:経過時間ではなく単にtでlow,hihを更新していた
# 達成可能か
#flg = (l<=low_next<=u)or(l<=high_next<=u)
#print(f"{i}: t:{t},l:{l},u:{u} | {low},{high}->{low_next},{high_next} | {flg}")
if(u < low_next)or(high_next < l):
is_available = False
#low,high = low_next, high_next
#low,high = l,u # WAの理由: 時刻tでl<=height<=uなので,l,uに更新しないといけない
low,high = max(l,low_next), min(u,high_next) # WAの理由: 時刻tでl<=height<=uを達成可能 = low=l,high=uなわけではない, lまで行けないかもしれない
now_t = t
return is_available
# 入力
T = int(input())
for i in range(T):
if(check_available()):
print("Yes")
else:
print("No")
Submission Info
| Submission Time |
|
| Task |
C - Flapping Takahashi |
| User |
hiro716 |
| Language |
Python (PyPy 3.11-v7.3.20) |
| Score |
300 |
| Code Size |
1446 Byte |
| Status |
AC |
| Exec Time |
393 ms |
| Memory |
111952 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt |
| All |
00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
64 ms |
93648 KiB |
| 01_small_00.txt |
AC |
393 ms |
110816 KiB |
| 01_small_01.txt |
AC |
328 ms |
111532 KiB |
| 01_small_02.txt |
AC |
305 ms |
111416 KiB |
| 01_small_03.txt |
AC |
283 ms |
111072 KiB |
| 01_small_04.txt |
AC |
258 ms |
111952 KiB |
| 01_small_05.txt |
AC |
225 ms |
110448 KiB |
| 01_small_06.txt |
AC |
211 ms |
110196 KiB |
| 01_small_07.txt |
AC |
195 ms |
109892 KiB |
| 02_random_00.txt |
AC |
150 ms |
109416 KiB |
| 02_random_01.txt |
AC |
165 ms |
109524 KiB |
| 02_random_02.txt |
AC |
164 ms |
109492 KiB |
| 02_random_03.txt |
AC |
157 ms |
109476 KiB |
| 02_random_04.txt |
AC |
170 ms |
109484 KiB |
| 02_random_05.txt |
AC |
164 ms |
109352 KiB |
| 02_random_06.txt |
AC |
149 ms |
109536 KiB |
| 02_random_07.txt |
AC |
163 ms |
109404 KiB |
| 02_random_08.txt |
AC |
177 ms |
109392 KiB |
| 02_random_09.txt |
AC |
136 ms |
109508 KiB |
| 02_random_10.txt |
AC |
169 ms |
109484 KiB |
| 02_random_11.txt |
AC |
173 ms |
109476 KiB |
| 02_random_12.txt |
AC |
170 ms |
109684 KiB |
| 02_random_13.txt |
AC |
177 ms |
109572 KiB |
| 02_random_14.txt |
AC |
177 ms |
109604 KiB |
| 02_random_15.txt |
AC |
174 ms |
109380 KiB |
| 02_random_16.txt |
AC |
176 ms |
109704 KiB |
| 02_random_17.txt |
AC |
176 ms |
109496 KiB |
| 02_random_18.txt |
AC |
176 ms |
109624 KiB |
| 02_random_19.txt |
AC |
180 ms |
109668 KiB |