結果
問題 | No.2627 Unnatural Pitch |
ユーザー | Taro Tanaka |
提出日時 | 2024-02-09 23:17:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,234 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 82,644 KB |
実行使用メモリ | 114,700 KB |
最終ジャッジ日時 | 2024-09-28 16:29:44 |
合計ジャッジ時間 | 4,119 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
53,148 KB |
testcase_01 | AC | 32 ms
53,712 KB |
testcase_02 | AC | 60 ms
77,004 KB |
testcase_03 | AC | 33 ms
54,096 KB |
testcase_04 | AC | 87 ms
100,520 KB |
testcase_05 | AC | 86 ms
100,512 KB |
testcase_06 | AC | 127 ms
111,848 KB |
testcase_07 | AC | 106 ms
108,692 KB |
testcase_08 | AC | 112 ms
107,652 KB |
testcase_09 | AC | 147 ms
112,576 KB |
testcase_10 | AC | 145 ms
112,404 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 77 ms
76,640 KB |
testcase_15 | WA | - |
testcase_16 | AC | 178 ms
107,548 KB |
testcase_17 | AC | 188 ms
114,700 KB |
testcase_18 | AC | 177 ms
104,360 KB |
testcase_19 | AC | 184 ms
110,104 KB |
testcase_20 | AC | 111 ms
87,568 KB |
testcase_21 | AC | 128 ms
90,908 KB |
testcase_22 | WA | - |
testcase_23 | AC | 127 ms
90,648 KB |
testcase_24 | WA | - |
testcase_25 | AC | 137 ms
96,276 KB |
ソースコード
from bisect import bisect_right N,K,L,U = map(int,input().split()) A = list(map(int,input().split())) A.sort() now_li = 0 now_ui = bisect_right(A,U-L+A[0]) - 1 now_l = A[0] if now_ui == N-1: print(0) else: while now_ui < N-1: prev_l = now_l if A[now_ui+1] - (now_l + U - L) < A[now_li+1] - now_l: now_l = A[now_ui+1] - U + L now_ui += 1 else: now_l = A[now_li] now_li += 1 if N - 1 - now_ui <= now_li: break now_u = now_l + U - L ans = 0 k_list1 = [0]*K k_list2 = [0]*K for a in A: ans += max(now_l - a + K - 1, 0)//K if a < now_l: k_list1[a%K]+=1 ans += max(a - now_u + K - 1, 0)//K if now_u - K < a: k_list2[a%K]+=1 max_ans = ans for i in range(1,K-1): ans -= k_list1[(now_l-i)%K] ans += k_list2[(now_u-i+1)%K] max_ans = min(ans, max_ans) k_list1 = [0]*K k_list2 = [0]*K for a in A: ans += max(now_l - a + K - 1, 0)//K if a < now_l + K: k_list1[a%K]+=1 ans += max(a - now_u + K - 1, 0)//K if now_u < a: k_list2[a%K]+=1 for i in range(1,K-1): ans += k_list1[(now_l+i-1)%K] ans -= k_list2[(now_u+i)%K] max_ans = min(ans, max_ans) #print(max_ans) now_l = prev_l now_u = now_l + U - L ans = 0 k_list1 = [0]*K k_list2 = [0]*K for a in A: ans += max(now_l - a + K - 1, 0)//K if a < now_l: k_list1[a%K]+=1 ans += max(a - now_u + K - 1, 0)//K if now_u - K < a: k_list2[a%K]+=1 max_ans = min(ans, max_ans) for i in range(1,K-1): ans -= k_list1[(now_l-i)%K] ans += k_list2[(now_u-i+1)%K] max_ans = min(ans, max_ans) k_list1 = [0]*K k_list2 = [0]*K for a in A: ans += max(now_l - a + K - 1, 0)//K if a < now_l + K: k_list1[a%K]+=1 ans += max(a - now_u + K - 1, 0)//K if now_u < a: k_list2[a%K]+=1 for i in range(1,K-1): ans += k_list1[(now_l+i-1)%K] ans -= k_list2[(now_u+i)%K] max_ans = min(ans, max_ans) print(max_ans)