提出 #61547431


ソースコード 拡げる

#ifndef LOCALEGOR
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx2")
#endif

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)((x).size()))

const ll MOD = 1e9 + 7;
const ll INF = 3e18;
const ld PI = acosl(-1);

template <typename T> bool chmax(T &a, T val) {
    if (val > a) {
        a = val;
        return true;
    }
    return false;
}
template <typename T> bool chmin(T &a, T val) {
    if (val < a) {
        a = val;
        return true;
    }
    return false;
}

void yep(bool f = 1) { cout << (f ? "YES\n" : "NO\n"); }
void nope(bool f = 1) { yep(!f); }
void nosol() { cout << -1 << '\n'; }

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int l = 0;
    int ans = 0;
    for (int r = 0; r < n; ++r) {
        while (a[l] * 2 <= a[r]) {
            ++l;
        }
        ans += l;
    }
    cout << ans << '\n';
}

signed main() {
#ifdef LOCALEGOR
    freopen("INPUT.txt", "r", stdin);
    // freopen("OUTPUT.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif // LOCALEGOR
    cout << fixed << setprecision(12);
    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

提出情報

提出日時
問題 C - Various Kagamimochi
ユーザ sputn1k
言語 C++ 20 (gcc 12.2)
得点 300
コード長 1843 Byte
結果 AC
実行時間 30 ms
メモリ 7144 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 30
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 02_handmade_23.txt, 02_handmade_24.txt, 02_handmade_25.txt, 02_handmade_26.txt, 02_handmade_27.txt, 02_handmade_28.txt, 02_handmade_29.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3420 KiB
00_sample_01.txt AC 1 ms 3460 KiB
00_sample_02.txt AC 1 ms 3504 KiB
01_random_03.txt AC 29 ms 7052 KiB
01_random_04.txt AC 29 ms 7000 KiB
01_random_05.txt AC 29 ms 7000 KiB
01_random_06.txt AC 29 ms 7052 KiB
01_random_07.txt AC 30 ms 7120 KiB
01_random_08.txt AC 29 ms 6988 KiB
01_random_09.txt AC 30 ms 7000 KiB
01_random_10.txt AC 16 ms 5200 KiB
01_random_11.txt AC 10 ms 4432 KiB
01_random_12.txt AC 5 ms 3620 KiB
01_random_13.txt AC 22 ms 7040 KiB
01_random_14.txt AC 22 ms 7144 KiB
01_random_15.txt AC 22 ms 7052 KiB
01_random_16.txt AC 26 ms 7040 KiB
01_random_17.txt AC 26 ms 7004 KiB
01_random_18.txt AC 26 ms 6988 KiB
01_random_19.txt AC 1 ms 3420 KiB
01_random_20.txt AC 1 ms 3464 KiB
01_random_21.txt AC 1 ms 3528 KiB
01_random_22.txt AC 1 ms 3436 KiB
02_handmade_23.txt AC 21 ms 7040 KiB
02_handmade_24.txt AC 8 ms 4476 KiB
02_handmade_25.txt AC 17 ms 6260 KiB
02_handmade_26.txt AC 3 ms 3684 KiB
02_handmade_27.txt AC 22 ms 6988 KiB
02_handmade_28.txt AC 27 ms 6988 KiB
02_handmade_29.txt AC 15 ms 7044 KiB