結果
問題 | No.2860 Heal Slimes |
ユーザー | square1001 |
提出日時 | 2024-07-15 13:29:08 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 579 ms / 2,000 ms |
コード長 | 976 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 32,820 KB |
最終ジャッジ日時 | 2024-07-15 13:29:30 |
合計ジャッジ時間 | 20,993 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 420 ms
10,880 KB |
testcase_01 | AC | 450 ms
10,880 KB |
testcase_02 | AC | 416 ms
10,752 KB |
testcase_03 | AC | 427 ms
10,880 KB |
testcase_04 | AC | 445 ms
10,880 KB |
testcase_05 | AC | 539 ms
10,880 KB |
testcase_06 | AC | 542 ms
10,880 KB |
testcase_07 | AC | 579 ms
11,008 KB |
testcase_08 | AC | 546 ms
10,752 KB |
testcase_09 | AC | 571 ms
10,752 KB |
testcase_10 | AC | 78 ms
11,264 KB |
testcase_11 | AC | 80 ms
11,264 KB |
testcase_12 | AC | 82 ms
11,264 KB |
testcase_13 | AC | 77 ms
11,264 KB |
testcase_14 | AC | 79 ms
11,264 KB |
testcase_15 | AC | 253 ms
11,136 KB |
testcase_16 | AC | 263 ms
11,264 KB |
testcase_17 | AC | 251 ms
11,392 KB |
testcase_18 | AC | 250 ms
11,264 KB |
testcase_19 | AC | 253 ms
11,392 KB |
testcase_20 | AC | 231 ms
27,056 KB |
testcase_21 | AC | 226 ms
27,728 KB |
testcase_22 | AC | 150 ms
21,316 KB |
testcase_23 | AC | 284 ms
32,416 KB |
testcase_24 | AC | 261 ms
30,656 KB |
testcase_25 | AC | 132 ms
25,336 KB |
testcase_26 | AC | 111 ms
20,368 KB |
testcase_27 | AC | 169 ms
27,356 KB |
testcase_28 | AC | 169 ms
30,532 KB |
testcase_29 | AC | 134 ms
25,756 KB |
testcase_30 | AC | 174 ms
30,892 KB |
testcase_31 | AC | 192 ms
31,516 KB |
testcase_32 | AC | 185 ms
31,216 KB |
testcase_33 | AC | 200 ms
30,504 KB |
testcase_34 | AC | 188 ms
32,752 KB |
testcase_35 | AC | 181 ms
30,840 KB |
testcase_36 | AC | 177 ms
31,344 KB |
testcase_37 | AC | 183 ms
30,672 KB |
testcase_38 | AC | 180 ms
31,604 KB |
testcase_39 | AC | 201 ms
30,960 KB |
testcase_40 | AC | 292 ms
32,688 KB |
testcase_41 | AC | 303 ms
32,684 KB |
testcase_42 | AC | 290 ms
32,816 KB |
testcase_43 | AC | 313 ms
32,684 KB |
testcase_44 | AC | 289 ms
32,684 KB |
testcase_45 | AC | 285 ms
32,816 KB |
testcase_46 | AC | 285 ms
32,684 KB |
testcase_47 | AC | 286 ms
32,684 KB |
testcase_48 | AC | 308 ms
32,816 KB |
testcase_49 | AC | 272 ms
32,692 KB |
testcase_50 | AC | 276 ms
32,688 KB |
testcase_51 | AC | 288 ms
32,692 KB |
testcase_52 | AC | 310 ms
32,820 KB |
testcase_53 | AC | 276 ms
32,692 KB |
testcase_54 | AC | 287 ms
32,684 KB |
testcase_55 | AC | 286 ms
32,816 KB |
testcase_56 | AC | 293 ms
32,720 KB |
testcase_57 | AC | 293 ms
32,688 KB |
testcase_58 | AC | 282 ms
32,812 KB |
testcase_59 | AC | 288 ms
32,688 KB |
ソースコード
# divide (a[0] + a[1] * x + ... + a[n-1] * x^(n-1)) by (1 + x + ... + x^(k-1)) def flat_division(n, a, k): b = [0] * (n+1) for i in range(n): b[i] -= a[i] b[i+1] += a[i] c = [0] * (n-k+1) for i in range(n-k, -1, -1): c[i] = b[i+k] b[i] += b[i+k] b[i+k] = 0 return c def solve(n, k, a): v = [0] * k for i in range(n): v[i%k] += a[i] if n % k == 0: if v != [v[0]] * k: return False b = flat_division(n, a, k) return all(i % k == 0 or b[i] <= 0 for i in range(n-k+1)) else: x = v[0] - v[-1] for i in range(k): if v[i] != (v[0] if i < n % k else v[-1]): return False for i in range(n): a[i] -= x b = flat_division(n, a, k) return all(b[i] <= 0 for i in range(n-k+1)) T = int(input()) for _ in range(T): n, k, x = map(int, input().split()) h = list(map(int, input().split())) if not all(h[i] % x == h[0] % x for i in range(n)): print('No') else: for i in range(n): h[i] //= x print('Yes' if solve(n, k, h) else 'No')