結果

問題 No.1268 Fruit Rush 2
ユーザー Fu_LFu_L
提出日時 2024-03-02 15:05:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 2,487 ms
コンパイル使用メモリ 206,900 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-02 15:05:40
合計ジャッジ時間 6,107 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 41 ms
6,676 KB
testcase_27 AC 41 ms
6,676 KB
testcase_28 AC 42 ms
6,676 KB
testcase_29 AC 42 ms
6,676 KB
testcase_30 AC 41 ms
6,676 KB
testcase_31 AC 49 ms
6,676 KB
testcase_32 AC 50 ms
6,676 KB
testcase_33 AC 54 ms
6,676 KB
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = n;
    rep(i, 0, n - 1) {
        if(a[i + 1] - a[i] != 1) continue;
        ll left = i + 1, right = n;
        while(right - left > 1) {
            ll mid = (left + right) / 2;
            if(a[mid] - a[i] == mid - i) {
                left = mid;
            } else {
                right = mid;
            }
        }
        ans += (left - i + 1) / 2;
    }
    cout << ans << '\n';
}
0