結果
問題 | No.1079 まお |
ユーザー | maspy |
提出日時 | 2020-05-15 06:43:05 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 856 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 47,892 KB |
最終ジャッジ日時 | 2024-04-09 22:09:59 |
合計ジャッジ時間 | 8,852 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
10,880 KB |
testcase_01 | AC | 25 ms
10,752 KB |
testcase_02 | AC | 25 ms
10,880 KB |
testcase_03 | AC | 24 ms
10,880 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 206 ms
28,976 KB |
testcase_13 | AC | 240 ms
29,356 KB |
testcase_14 | AC | 284 ms
29,960 KB |
testcase_15 | AC | 320 ms
30,460 KB |
testcase_16 | AC | 369 ms
32,024 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 427 ms
47,736 KB |
testcase_23 | AC | 432 ms
47,892 KB |
testcase_24 | AC | 430 ms
47,712 KB |
testcase_25 | AC | 417 ms
47,768 KB |
testcase_26 | AC | 434 ms
47,592 KB |
testcase_27 | AC | 249 ms
20,036 KB |
testcase_28 | AC | 336 ms
31,024 KB |
testcase_29 | AC | 324 ms
32,204 KB |
testcase_30 | AC | 303 ms
32,360 KB |
testcase_31 | AC | 301 ms
20,292 KB |
ソースコード
import sys from collections import defaultdict from heapq import heappop, heappush read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K, *A = map(int, read().split()) def add(i): x = A[i] heappush(q, x) counter[x] += 1 index_sum[x] += i def remove(i): x = A[i] counter[x] -= 1 index_sum[x] -= i # 最小元がqに存在することを保証 while q and counter[q[0]] == 0: heappop(q) q = [] counter = defaultdict(int) index_sum = defaultdict(int) # 左端 L を固定 # 極大な[L,R]を求める answer = 0 L = R = -1 for L in range(N): while R < N - 1: x = A[R + 1] if q and q[0] == x: break R += 1 add(R) answer += index_sum[K - A[L]] - (L - 1) * counter[K - A[L]] remove(L) print(answer)