結果

問題 No.1268 Fruit Rush 2
ユーザー Ricky_ponRicky_pon
提出日時 2020-10-24 19:55:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,552 bytes
コンパイル時間 2,461 ms
コンパイル使用メモリ 209,248 KB
実行使用メモリ 19,152 KB
最終ジャッジ日時 2023-09-28 20:42:44
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 134 ms
15,524 KB
testcase_17 AC 111 ms
13,652 KB
testcase_18 AC 120 ms
14,388 KB
testcase_19 AC 119 ms
14,144 KB
testcase_20 AC 115 ms
14,096 KB
testcase_21 AC 114 ms
13,864 KB
testcase_22 AC 136 ms
15,484 KB
testcase_23 AC 135 ms
15,484 KB
testcase_24 AC 118 ms
14,280 KB
testcase_25 AC 114 ms
14,072 KB
testcase_26 AC 125 ms
19,040 KB
testcase_27 AC 127 ms
19,116 KB
testcase_28 AC 130 ms
19,080 KB
testcase_29 AC 126 ms
19,136 KB
testcase_30 AC 131 ms
19,076 KB
testcase_31 AC 195 ms
19,152 KB
testcase_32 AC 194 ms
19,124 KB
testcase_33 WA -
testcase_34 AC 176 ms
19,104 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

//#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n;
    scanf("%d", &n);
    lint a[n], dp[n];
    map<lint, int> mp;
    memset(dp, 0, sizeof(dp));
    rep(i, n) scanf("%lld", &a[i]);
    sort(a, a + n);
    rep(i, n) mp[a[i]] = i;
    rrep(i, n) if (dp[i] == 0) {
        dp[i] = 1;
        int t = a[i] - 2;
        while (t > 0 && mp.find(t) != mp.end()) {
            dp[mp[t]] = dp[mp[t + 2]] + 1;
            t -= 2;
        }
    }
    lint ans = n;
    rep(i, n - 1) if (a[i] + 1 == a[i + 1]) ans += dp[i + 1];
    printf("%lld\n", ans);
}
0