結果

問題 No.1268 Fruit Rush 2
ユーザー ocvret_ocvret_
提出日時 2020-10-24 11:45:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 773 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 171,288 KB
実行使用メモリ 19,164 KB
最終ジャッジ日時 2023-09-28 20:21:02
合計ジャッジ時間 7,576 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,416 KB
testcase_01 AC 3 ms
4,508 KB
testcase_02 AC 3 ms
4,400 KB
testcase_03 AC 3 ms
4,596 KB
testcase_04 AC 3 ms
4,568 KB
testcase_05 AC 3 ms
4,564 KB
testcase_06 AC 3 ms
4,508 KB
testcase_07 AC 2 ms
4,592 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,600 KB
testcase_11 AC 3 ms
4,580 KB
testcase_12 AC 2 ms
4,400 KB
testcase_13 AC 3 ms
4,644 KB
testcase_14 AC 3 ms
4,600 KB
testcase_15 AC 2 ms
4,580 KB
testcase_16 AC 62 ms
6,392 KB
testcase_17 AC 54 ms
6,452 KB
testcase_18 AC 57 ms
6,280 KB
testcase_19 AC 56 ms
6,284 KB
testcase_20 AC 56 ms
6,496 KB
testcase_21 AC 54 ms
6,160 KB
testcase_22 AC 63 ms
6,444 KB
testcase_23 AC 63 ms
6,596 KB
testcase_24 AC 56 ms
6,300 KB
testcase_25 AC 55 ms
6,208 KB
testcase_26 AC 100 ms
6,924 KB
testcase_27 AC 100 ms
7,000 KB
testcase_28 AC 100 ms
7,276 KB
testcase_29 AC 100 ms
6,948 KB
testcase_30 AC 99 ms
7,008 KB
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
  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