結果

問題 No.1268 Fruit Rush 2
ユーザー stoqstoq
提出日時 2020-05-31 09:03:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 486 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 68,460 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-04 08:32:32
合計ジャッジ時間 4,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,204 KB
testcase_01 AC 3 ms
5,068 KB
testcase_02 AC 3 ms
5,040 KB
testcase_03 AC 3 ms
5,060 KB
testcase_04 AC 3 ms
5,052 KB
testcase_05 AC 3 ms
5,052 KB
testcase_06 AC 4 ms
5,200 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 3 ms
5,048 KB
testcase_10 AC 3 ms
5,076 KB
testcase_11 AC 3 ms
5,036 KB
testcase_12 RE -
testcase_13 AC 3 ms
5,088 KB
testcase_14 AC 4 ms
5,188 KB
testcase_15 RE -
testcase_16 AC 47 ms
5,060 KB
testcase_17 AC 40 ms
5,060 KB
testcase_18 AC 41 ms
5,052 KB
testcase_19 AC 42 ms
5,208 KB
testcase_20 AC 41 ms
5,052 KB
testcase_21 AC 40 ms
5,256 KB
testcase_22 AC 45 ms
5,148 KB
testcase_23 AC 45 ms
5,040 KB
testcase_24 AC 41 ms
5,092 KB
testcase_25 AC 40 ms
5,060 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 56 ms
5,104 KB
testcase_32 AC 57 ms
5,060 KB
testcase_33 RE -
testcase_34 WA -
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0