結果
問題 | No.1347 HS Railway |
ユーザー | mkawa2 |
提出日時 | 2021-09-07 00:08:27 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 583 ms / 2,000 ms |
コード長 | 1,377 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 13,184 KB |
実行使用メモリ | 27,876 KB |
最終ジャッジ日時 | 2024-06-02 03:38:32 |
合計ジャッジ時間 | 13,690 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
11,008 KB |
testcase_01 | AC | 30 ms
10,880 KB |
testcase_02 | AC | 29 ms
11,008 KB |
testcase_03 | AC | 28 ms
10,880 KB |
testcase_04 | AC | 26 ms
11,136 KB |
testcase_05 | AC | 26 ms
11,008 KB |
testcase_06 | AC | 26 ms
11,008 KB |
testcase_07 | AC | 27 ms
11,008 KB |
testcase_08 | AC | 29 ms
11,008 KB |
testcase_09 | AC | 27 ms
11,008 KB |
testcase_10 | AC | 27 ms
11,008 KB |
testcase_11 | AC | 27 ms
10,880 KB |
testcase_12 | AC | 125 ms
14,976 KB |
testcase_13 | AC | 124 ms
13,696 KB |
testcase_14 | AC | 67 ms
12,800 KB |
testcase_15 | AC | 75 ms
17,752 KB |
testcase_16 | AC | 170 ms
18,980 KB |
testcase_17 | AC | 53 ms
11,648 KB |
testcase_18 | AC | 226 ms
19,212 KB |
testcase_19 | AC | 256 ms
16,896 KB |
testcase_20 | AC | 186 ms
21,948 KB |
testcase_21 | AC | 80 ms
17,960 KB |
testcase_22 | AC | 253 ms
24,016 KB |
testcase_23 | AC | 244 ms
18,820 KB |
testcase_24 | AC | 109 ms
14,128 KB |
testcase_25 | AC | 182 ms
15,944 KB |
testcase_26 | AC | 260 ms
20,820 KB |
testcase_27 | AC | 150 ms
16,472 KB |
testcase_28 | AC | 237 ms
27,876 KB |
testcase_29 | AC | 262 ms
23,888 KB |
testcase_30 | AC | 211 ms
18,972 KB |
testcase_31 | AC | 204 ms
19,108 KB |
testcase_32 | AC | 301 ms
22,416 KB |
testcase_33 | AC | 304 ms
25,452 KB |
testcase_34 | AC | 297 ms
23,332 KB |
testcase_35 | AC | 286 ms
22,432 KB |
testcase_36 | AC | 339 ms
22,308 KB |
testcase_37 | AC | 352 ms
24,756 KB |
testcase_38 | AC | 345 ms
25,300 KB |
testcase_39 | AC | 395 ms
24,752 KB |
testcase_40 | AC | 269 ms
20,932 KB |
testcase_41 | AC | 276 ms
21,700 KB |
testcase_42 | AC | 547 ms
23,772 KB |
testcase_43 | AC | 334 ms
22,132 KB |
testcase_44 | AC | 407 ms
21,276 KB |
testcase_45 | AC | 383 ms
20,620 KB |
testcase_46 | AC | 402 ms
23,512 KB |
testcase_47 | AC | 541 ms
22,688 KB |
testcase_48 | AC | 583 ms
26,844 KB |
testcase_49 | AC | 432 ms
22,756 KB |
testcase_50 | AC | 533 ms
24,880 KB |
testcase_51 | AC | 456 ms
23,152 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)