結果

問題 No.1268 Fruit Rush 2
ユーザー butsurizukibutsurizuki
提出日時 2020-10-24 00:39:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 953 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,774 ms
コンパイル使用メモリ 183,264 KB
実行使用メモリ 85,944 KB
最終ジャッジ日時 2023-09-28 19:46:19
合計ジャッジ時間 16,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 515 ms
37,088 KB
testcase_17 AC 448 ms
35,200 KB
testcase_18 AC 488 ms
36,308 KB
testcase_19 AC 470 ms
36,040 KB
testcase_20 AC 467 ms
35,732 KB
testcase_21 AC 446 ms
35,528 KB
testcase_22 AC 632 ms
37,112 KB
testcase_23 AC 518 ms
37,324 KB
testcase_24 AC 473 ms
36,056 KB
testcase_25 AC 466 ms
35,592 KB
testcase_26 AC 934 ms
85,912 KB
testcase_27 AC 934 ms
85,944 KB
testcase_28 AC 950 ms
85,892 KB
testcase_29 AC 953 ms
85,900 KB
testcase_30 AC 942 ms
85,944 KB
testcase_31 AC 672 ms
39,040 KB
testcase_32 AC 661 ms
38,940 KB
testcase_33 AC 462 ms
38,952 KB
testcase_34 AC 561 ms
73,580 KB
testcase_35 AC 632 ms
73,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;


int main(){
  int n;
  cin >> n;
  vector<long long> vc(n);
  set<long long> st;
  map<long long,long long> dp;
  map<long long,long long> ex;
  for(int i=0;i<n;i++){
    cin >> vc[i];
    st.insert(vc[i]);
    st.insert(vc[i]+1);
    dp[vc[i]]=1;
    ex[vc[i]]=1;
  }
  sort(vc.begin(),vc.end());
  long long res=0;
  for(auto k:st){
    if(k>=3){
      if(ex[k-1]==1){dp[k]+=dp[k-2];}
    }
    res+=dp[k];
  }
  cout << res << '\n';
}
0