結果
問題 | No.1347 HS Railway |
ユーザー | mkawa2 |
提出日時 | 2021-09-07 00:08:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 716 ms / 2,000 ms |
コード長 | 1,377 bytes |
コンパイル時間 | 246 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 27,892 KB |
最終ジャッジ日時 | 2024-12-22 20:31:18 |
合計ジャッジ時間 | 16,357 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
11,008 KB |
testcase_01 | AC | 32 ms
11,008 KB |
testcase_02 | AC | 36 ms
11,008 KB |
testcase_03 | AC | 34 ms
10,880 KB |
testcase_04 | AC | 34 ms
10,880 KB |
testcase_05 | AC | 33 ms
10,880 KB |
testcase_06 | AC | 35 ms
10,880 KB |
testcase_07 | AC | 34 ms
10,880 KB |
testcase_08 | AC | 34 ms
10,880 KB |
testcase_09 | AC | 33 ms
11,008 KB |
testcase_10 | AC | 32 ms
10,880 KB |
testcase_11 | AC | 34 ms
10,880 KB |
testcase_12 | AC | 149 ms
14,976 KB |
testcase_13 | AC | 147 ms
13,696 KB |
testcase_14 | AC | 80 ms
12,672 KB |
testcase_15 | AC | 86 ms
17,492 KB |
testcase_16 | AC | 199 ms
18,856 KB |
testcase_17 | AC | 66 ms
11,520 KB |
testcase_18 | AC | 271 ms
19,208 KB |
testcase_19 | AC | 302 ms
16,768 KB |
testcase_20 | AC | 219 ms
21,952 KB |
testcase_21 | AC | 91 ms
18,176 KB |
testcase_22 | AC | 302 ms
24,000 KB |
testcase_23 | AC | 316 ms
18,836 KB |
testcase_24 | AC | 130 ms
14,128 KB |
testcase_25 | AC | 222 ms
15,820 KB |
testcase_26 | AC | 305 ms
20,692 KB |
testcase_27 | AC | 178 ms
16,348 KB |
testcase_28 | AC | 270 ms
27,892 KB |
testcase_29 | AC | 304 ms
23,888 KB |
testcase_30 | AC | 252 ms
19,092 KB |
testcase_31 | AC | 246 ms
18,980 KB |
testcase_32 | AC | 376 ms
22,412 KB |
testcase_33 | AC | 356 ms
25,324 KB |
testcase_34 | AC | 338 ms
23,336 KB |
testcase_35 | AC | 344 ms
22,564 KB |
testcase_36 | AC | 402 ms
22,436 KB |
testcase_37 | AC | 438 ms
24,628 KB |
testcase_38 | AC | 443 ms
25,300 KB |
testcase_39 | AC | 487 ms
24,880 KB |
testcase_40 | AC | 329 ms
20,816 KB |
testcase_41 | AC | 332 ms
21,444 KB |
testcase_42 | AC | 701 ms
23,520 KB |
testcase_43 | AC | 414 ms
22,132 KB |
testcase_44 | AC | 483 ms
21,144 KB |
testcase_45 | AC | 455 ms
20,872 KB |
testcase_46 | AC | 498 ms
23,288 KB |
testcase_47 | AC | 606 ms
22,440 KB |
testcase_48 | AC | 699 ms
26,844 KB |
testcase_49 | AC | 546 ms
23,008 KB |
testcase_50 | AC | 716 ms
24,976 KB |
testcase_51 | AC | 541 ms
23,080 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**20 # md = 998244353 md = 10**9+7 n = II() cs = [] lr = [] for i in range(5): l, r, *aa = LI() l, r = l-1, r-1 lr.append((l, r)) s = [0] for a in aa: s.append(s[-1]+a) cs.append(s) ss = [[] for _ in range(5)] for _ in range(II()): i, s = LI() ss[i-1].append(s) for i in range(5):ss[i].sort() ans = 0 for j in range(5): l1, r1 = lr[j] for i in range(j): l0, r0 = lr[i] l = max(l0, l1) r = min(r0, r1) if l>r:continue u = v = 0 d = cs[j][l-l1]-cs[i][l-l0] e = cs[j][r-l1]-cs[i][r-l0] for s in ss[j]: while u < len(ss[i]) and s+d > ss[i][u]: u += 1 if u==len(ss[i]):break while v < len(ss[i]) and s+e >= ss[i][v]: v += 1 ans += v-u print(ans)