結果
| 問題 |
No.1268 Fruit Rush 2
|
| ユーザー |
ocvret_
|
| 提出日時 | 2020-10-24 11:45:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 773 bytes |
| コンパイル時間 | 1,649 ms |
| コンパイル使用メモリ | 172,756 KB |
| 実行使用メモリ | 22,048 KB |
| 最終ジャッジ日時 | 2024-07-21 15:08:26 |
| 合計ジャッジ時間 | 7,251 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 TLE * 1 -- * 4 |
ソースコード
#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;
}
ocvret_