結果

問題 No.1268 Fruit Rush 2
ユーザー ocvret_ocvret_
提出日時 2020-10-24 11:47:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 171,124 KB
実行使用メモリ 22,576 KB
最終ジャッジ日時 2023-09-28 20:21:07
合計ジャッジ時間 4,932 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,640 KB
testcase_01 AC 3 ms
4,500 KB
testcase_02 AC 3 ms
4,504 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,572 KB
testcase_05 AC 3 ms
4,572 KB
testcase_06 AC 3 ms
4,500 KB
testcase_07 AC 3 ms
4,568 KB
testcase_08 AC 3 ms
4,480 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,540 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,564 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,596 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 60 ms
6,460 KB
testcase_17 AC 53 ms
6,184 KB
testcase_18 AC 55 ms
6,180 KB
testcase_19 AC 54 ms
6,128 KB
testcase_20 AC 53 ms
6,176 KB
testcase_21 AC 52 ms
6,180 KB
testcase_22 AC 60 ms
6,396 KB
testcase_23 AC 60 ms
6,484 KB
testcase_24 AC 54 ms
6,124 KB
testcase_25 AC 53 ms
6,124 KB
testcase_26 AC 100 ms
6,920 KB
testcase_27 AC 100 ms
6,996 KB
testcase_28 AC 99 ms
6,976 KB
testcase_29 AC 100 ms
7,040 KB
testcase_30 AC 99 ms
7,060 KB
testcase_31 AC 83 ms
14,580 KB
testcase_32 AC 83 ms
14,660 KB
testcase_33 AC 143 ms
14,740 KB
testcase_34 AC 78 ms
22,576 KB
testcase_35 AC 148 ms
22,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<ll> dp(200100,-1);
ll dfs(vector<ll> &v,int pos){
  if(pos >= v.size())return 0;
  if(dp[pos] != -1)return dp[pos];
  ll res = 0;
  for(int i = 1;i <= 2;i++){
    if(pos+i >= v.size())break;
    if(v[pos+i]-v[pos] == 2)res += dfs(v,pos+i);
  }
  return dp[pos] = res+1;
}

int main(){
  
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  sort(ALL(v));
  vector<int> l(n);
  rep(i,n)dfs(v,i);
  ll res = n;
  for(int i = 1;i < n;i++)if(v[i]-v[i-1] == 1)res += dp[i];
  cout << res << "\n";


  return 0;
}
0