結果
問題 | No.1268 Fruit Rush 2 |
ユーザー |
|
提出日時 | 2020-10-24 00:39:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 908 ms / 2,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 2,004 ms |
コンパイル使用メモリ | 185,008 KB |
実行使用メモリ | 86,144 KB |
最終ジャッジ日時 | 2024-07-21 14:28:17 |
合計ジャッジ時間 | 15,580 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#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';}