結果
問題 | No.1535 五七五 |
ユーザー | Theta |
提出日時 | 2024-04-16 16:09:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 238 ms / 2,000 ms |
コード長 | 1,886 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 194,152 KB |
最終ジャッジ日時 | 2024-10-07 13:21:52 |
合計ジャッジ時間 | 4,010 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,288 KB |
testcase_01 | AC | 36 ms
53,348 KB |
testcase_02 | AC | 36 ms
53,440 KB |
testcase_03 | AC | 36 ms
53,932 KB |
testcase_04 | AC | 153 ms
173,256 KB |
testcase_05 | AC | 196 ms
187,644 KB |
testcase_06 | AC | 178 ms
189,492 KB |
testcase_07 | AC | 35 ms
52,864 KB |
testcase_08 | AC | 36 ms
52,648 KB |
testcase_09 | AC | 36 ms
53,028 KB |
testcase_10 | AC | 35 ms
52,312 KB |
testcase_11 | AC | 38 ms
52,492 KB |
testcase_12 | AC | 38 ms
52,768 KB |
testcase_13 | AC | 37 ms
52,196 KB |
testcase_14 | AC | 38 ms
52,828 KB |
testcase_15 | AC | 36 ms
52,988 KB |
testcase_16 | AC | 37 ms
53,700 KB |
testcase_17 | AC | 37 ms
52,960 KB |
testcase_18 | AC | 238 ms
194,152 KB |
testcase_19 | AC | 236 ms
193,664 KB |
testcase_20 | AC | 223 ms
193,536 KB |
testcase_21 | AC | 228 ms
193,784 KB |
testcase_22 | AC | 237 ms
194,004 KB |
testcase_23 | AC | 224 ms
194,012 KB |
ソースコード
from itertools import accumulate def main(): N = int(input()) a, b, c = map(int, input().split()) S = list(map(len, input().split())) S_accum = list(accumulate(S, initial=0)) patterns = 0 head_idx = 0 ab_idx = 1 bc_idx = 2 tail_idx = 3 part_a = S[0] part_b = S[1] part_c = S[2] while head_idx < N - 2 and tail_idx <= N: if part_a == a and part_b == b and part_c == c: patterns += 1 if tail_idx >= N: break part_c += S[tail_idx] tail_idx += 1 part_c -= S[bc_idx] part_b += S[bc_idx] bc_idx += 1 part_b -= S[ab_idx] part_a += S[ab_idx] ab_idx += 1 part_a -= S[head_idx] head_idx += 1 continue if head_idx >= ab_idx: part_a += S[ab_idx] part_b -= S[ab_idx] ab_idx += 1 continue if ab_idx >= bc_idx: part_b += S[bc_idx] part_c -= S[bc_idx] bc_idx += 1 continue if bc_idx >= tail_idx: if tail_idx >= N: break part_c += S[tail_idx] tail_idx += 1 continue if part_c < c: if tail_idx >= N: break part_c += S[tail_idx] tail_idx += 1 continue if part_c > c or part_b < b: part_c -= S[bc_idx] part_b += S[bc_idx] bc_idx += 1 continue if part_b > b or part_a < a: part_b -= S[ab_idx] part_a += S[ab_idx] ab_idx += 1 continue if part_a > a: part_a -= S[head_idx] head_idx += 1 continue print(patterns) if __name__ == "__main__": main()