結果

問題 No.1268 Fruit Rush 2
ユーザー butsurizuki
提出日時 2020-10-24 00:30:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 182,476 KB
実行使用メモリ 72,832 KB
最終ジャッジ日時 2024-07-21 14:21:18
合計ジャッジ時間 10,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;


int main(){
  int n;
  cin >> n;
  vector<int> vc(n);
  set<int> 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