結果

問題 No.2486 Don't come next to me
ユーザー kobaryo222kobaryo222
提出日時 2023-09-29 21:34:14
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,725 bytes
コンパイル時間 4,223 ms
コンパイル使用メモリ 288,788 KB
実行使用メモリ 299,492 KB
最終ジャッジ日時 2023-09-29 21:34:26
合計ジャッジ時間 11,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pl = pair<ll, ll>;

#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>
#define vm vector<mint>
#define vvm vector<vm>
#define vvvm vector<vvm>
#define vp vector<pl>
#define vvp vector<vp>
#define vvvp vector<vvp>
#define vs vector<string>
#define vvs vector<vs>
#define vb vector<bool>
#define vvb vector<vb>
#define vvvb vector<vvb>
#define vd vector<double>
#define vvd vector<vd>
#define vvvd vector<vd>

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) std::begin(x), std::end(x)
#define make_unique(v) v.erase(unique(all(v)), v.end());
#define sum(...) accumulate(all(__VA_ARGS__), 0LL)
#define inf (0x1fffffffffffffffLL)

template<class... T>
void input(T&... a){
    (cin >> ... >> a);
}

template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for(auto &x : v) {
        is >> x;
    }
    return is;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++) {
        if(i != (int)v.size() - 1)
            os << v[i] << " ";
        else
            os << v[i];
    }
    return os;
}

template <typename T, typename... Args>
auto make_v(T x, int arg, Args... args) {
    if constexpr(sizeof...(args) == 0)
        return vector<T>(arg, x);
    else
        return vector(arg, make_v<T>(x, args...));
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}

template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}

template <class T>
bool chmin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

template <class T>
bool chmax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    ll N, M;
    cin >> N >> M;
    vl A(M);
    cin >> A;
    map<ll, ll> mp;
    auto f = [&](auto self, ll n) -> ll
    {
        if(mp.contains(n)) return mp[n];
        else if(n <= 0) return mp[n] = 0;
        else if(n == 1) return mp[n] = 1;
        else if(n % 2 == 1) return mp[n] = 2 * self(self, (n - 1) / 2);
        else return mp[n] = 2 * max(1 + self(self, n / 2 - 1), self(self, n / 2));
    };
    ll ans = 0;
    rep(i, M - 1){
        ans += f(f, A[i + 1] - A[i] - 1);
    }
    cout << ans << endl;
}
0