結果
| 問題 |
No.1268 Fruit Rush 2
|
| ユーザー |
stoq
|
| 提出日時 | 2020-05-31 09:03:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 486 bytes |
| コンパイル時間 | 965 ms |
| コンパイル使用メモリ | 66,304 KB |
| 最終ジャッジ日時 | 2025-01-10 19:59:30 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 1 RE * 11 |
ソースコード
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
int n;
cin >> n;
bool exist[200010] = {};
for (int i = 0; i < n; i++)
{
int a;
cin >> a;
exist[a] = true;
}
ll dp[200010] = {};
dp[1] = exist[1], dp[2] = exist[2];
for (int i = 3; i < 200005; i++)
{
dp[i] += exist[i];
if (exist[i - 1])
dp[i] += dp[i - 2];
}
ll sum = 0;
for (int i = 1; i < 200010; i++)
sum += dp[i];
cout << sum << endl;
return 0;
}
stoq