Submission #70863230


Source Code Expand

"""
<方針>
- 全ての組み合わせするのは明らかに間に合わない `O(N!M!)`
- 小さい `B` は、なるべく小さい `H` だったら対応できるかも
- その個数が `K` を超えるかを考えれば良い
- この個数の列挙は、`O(N+M)` で行けそう
- だけど、最初にソートするから、そこで `O(NlogN+MlogM)` になるけど、間に合いそう
"""
# 入力
N, M, K = map(int, input().split())
H = list(map(int, input().split()))
B = list(map(int, input().split()))

# ソート
H.sort()
B.sort()

# ロボットが作れる個数
cnt = 0

# 今見てるHのインデックス
indH = 0

# Bから見ていく
for i in range(M):
  h = H[indH]
  b = B[i]
  
  # ロボット作れそう
  if(h<=b):
    cnt += 1
    indH += 1
    # Hのパーツがもうない
    if(indH == N):
      break

# K個以上作れそうかどうか
if(cnt >= K):
  print("Yes")
else:
  print("No")

Submission Info

Submission Time
Task C - Robot Factory
User mattsunkun
Language Python (PyPy 3.11-v7.3.20)
Score 300
Code Size 969 Byte
Status AC
Exec Time 174 ms
Memory 147452 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 58 ms 79820 KiB
00_sample_01.txt AC 58 ms 80016 KiB
00_sample_02.txt AC 58 ms 79748 KiB
00_sample_03.txt AC 58 ms 79960 KiB
01_random_03.txt AC 172 ms 146040 KiB
01_random_04.txt AC 172 ms 145920 KiB
01_random_05.txt AC 173 ms 146228 KiB
01_random_06.txt AC 174 ms 146180 KiB
01_random_07.txt AC 172 ms 146448 KiB
01_random_08.txt AC 172 ms 146260 KiB
01_random_09.txt AC 173 ms 146104 KiB
01_random_10.txt AC 173 ms 145912 KiB
01_random_11.txt AC 173 ms 146024 KiB
01_random_12.txt AC 114 ms 133956 KiB
01_random_13.txt AC 119 ms 138016 KiB
01_random_14.txt AC 141 ms 140436 KiB
01_random_15.txt AC 96 ms 115996 KiB
01_random_16.txt AC 93 ms 112992 KiB
01_random_17.txt AC 98 ms 118284 KiB
01_random_18.txt AC 173 ms 146624 KiB
01_random_19.txt AC 174 ms 146800 KiB
01_random_20.txt AC 173 ms 146492 KiB
01_random_21.txt AC 174 ms 147452 KiB
01_random_22.txt AC 173 ms 145888 KiB
01_random_23.txt AC 114 ms 133380 KiB
01_random_24.txt AC 67 ms 90244 KiB
01_random_25.txt AC 169 ms 145496 KiB
01_random_26.txt AC 172 ms 145456 KiB
01_random_27.txt AC 173 ms 146008 KiB
01_random_28.txt AC 172 ms 145584 KiB
01_random_29.txt AC 172 ms 145856 KiB
01_random_30.txt AC 174 ms 146244 KiB
01_random_31.txt AC 136 ms 142004 KiB
01_random_32.txt AC 146 ms 139696 KiB
01_random_33.txt AC 141 ms 142032 KiB