結果
| 問題 |
No.1268 Fruit Rush 2
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-10-23 23:02:49 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 477 ms / 2,000 ms |
| コード長 | 304 bytes |
| コンパイル時間 | 1,081 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 45,256 KB |
| 最終ジャッジ日時 | 2024-07-21 12:20:44 |
| 合計ジャッジ時間 | 9,821 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
dp = {}
for i in range(n):
if a[i] not in dp:
dp[a[i]] = 0
if i >= 1 and a[i] == a[i - 1] + 1:
dp[a[i]] += 1
if i >= 2 and a[i] - 2 in dp:
dp[a[i]] += dp[a[i] - 2]
ans += dp[a[i]] + 1
print(ans)
trineutron