結果

問題 No.1268 Fruit Rush 2
ユーザー outlineoutline
提出日時 2021-01-01 14:35:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 145,512 KB
実行使用メモリ 42,240 KB
最終ジャッジ日時 2024-04-19 11:08:54
合計ジャッジ時間 6,682 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 113 ms
16,768 KB
testcase_17 AC 98 ms
16,256 KB
testcase_18 AC 102 ms
16,512 KB
testcase_19 AC 103 ms
16,384 KB
testcase_20 AC 107 ms
16,384 KB
testcase_21 AC 97 ms
16,256 KB
testcase_22 AC 114 ms
16,640 KB
testcase_23 AC 115 ms
16,896 KB
testcase_24 AC 110 ms
16,384 KB
testcase_25 AC 99 ms
16,384 KB
testcase_26 AC 212 ms
42,240 KB
testcase_27 AC 228 ms
42,240 KB
testcase_28 AC 211 ms
42,240 KB
testcase_29 AC 224 ms
42,240 KB
testcase_30 AC 217 ms
42,240 KB
testcase_31 AC 162 ms
17,280 KB
testcase_32 AC 151 ms
17,280 KB
testcase_33 AC 175 ms
17,280 KB
testcase_34 AC 192 ms
29,824 KB
testcase_35 AC 219 ms
29,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(begin(a), end(a));

    map<ll, ll> dp;
    dp[a[0]] = 1;
    for(int i = 1; i < n; ++i){
        dp[a[i] + 1] += dp[a[i] - 1];
        dp[a[i]] += 1;
    }

    ll ans = 0;
    for(auto [key, val] : dp)   ans += val;
    cout << ans << endl;

    return 0;
}
0