結果
| 問題 |
No.1268 Fruit Rush 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-06 16:34:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 177 ms / 2,000 ms |
| コード長 | 322 bytes |
| コンパイル時間 | 334 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 141,952 KB |
| 最終ジャッジ日時 | 2024-06-11 13:47:57 |
| 合計ジャッジ時間 | 6,289 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = sorted(map(int, input().split()))
d = {a: i for i, a in enumerate(A)}
table2 = [0] * N
ans = N
for i in range(N - 1, -1, -1):
if A[i] + 2 in d:
table2[i] = table2[d[A[i] + 2]] + 1
if A[i] - 1 in d:
ans += table2[i] + 1
print(ans)