Submission #61554238


Source Code Expand

#ifndef ATCODER // AtCoder 環境でない場合はデバッグモードを有効にする. コンパイルにすごく時間がかかる!
#define _GLIBCXX_DEBUG // out of rangeを検出してくれる。#include<bits/stdc++.h>の前に記述する必要あり
#endif
#include<bits/stdc++.h>
using namespace std;
struct IOSetup {
    IOSetup() {
        // 実行が高速化するコード
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        // 小数点以下10桁まで(四捨五入)
        cout << fixed << setprecision(10);
    }
} iosetup;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, b, a) for (int i = b; i > a; i--)
#define rep3(i, a, b, d) for (int i = a; i < b; i+=d)
#define rrep3(i, b, a, d) for (int i = b; i > a; i-=d)
#define between(x, a, b) (((a) <= (x)) && ((x) < (b)))

// Template function to print various container types
template<typename Container>
void print(const Container& a) {
    cout << "{";
    bool first = true;
    for (const auto& i : a) {
        if (!first) {
            cout << ",";
        }
        cout << i;
        first = false;
    }
    cout << "}" << endl;
}


// Template function to print 2D vector
template<typename T>
void printvec2d(const vector<vector<T>>& a) {
    size_t rows = a.size();
    for (size_t i = 0; i < rows; ++i) {
        print(a[i]);
    }
}

// Template function to print 3D vector
template<typename T>
void printvec3d(const vector<vector<vector<T>>>& a) {
    size_t depth = a.size();
    for (size_t i = 0; i < depth; ++i) {
        printvec2d(a[i]);
        cout << endl;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    long long cnt = 0;
    rep(i, n) {
        int now = a[i];
        auto it = upper_bound(a.begin(), a.end(), now / 2); // vector用! 値の参照は*it. はみ出すとit = vec.end()
        cnt += it - a.begin();
    }
    cout << cnt;
}

Submission Info

Submission Time
Task C - Various Kagamimochi
User kazuki00
Language C++ 23 (gcc 12.2)
Score 300
Code Size 2079 Byte
Status AC
Exec Time 51 ms
Memory 5184 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 30
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3428 KiB
00_sample_01.txt AC 1 ms 3496 KiB
00_sample_02.txt AC 1 ms 3564 KiB
01_random_03.txt AC 50 ms 4888 KiB
01_random_04.txt AC 50 ms 4884 KiB
01_random_05.txt AC 50 ms 4888 KiB
01_random_06.txt AC 49 ms 4852 KiB
01_random_07.txt AC 50 ms 4900 KiB
01_random_08.txt AC 50 ms 4944 KiB
01_random_09.txt AC 50 ms 4876 KiB
01_random_10.txt AC 26 ms 4148 KiB
01_random_11.txt AC 16 ms 3472 KiB
01_random_12.txt AC 8 ms 3496 KiB
01_random_13.txt AC 39 ms 4860 KiB
01_random_14.txt AC 38 ms 5168 KiB
01_random_15.txt AC 40 ms 4944 KiB
01_random_16.txt AC 50 ms 4904 KiB
01_random_17.txt AC 50 ms 5128 KiB
01_random_18.txt AC 50 ms 4944 KiB
01_random_19.txt AC 1 ms 3492 KiB
01_random_20.txt AC 1 ms 3484 KiB
01_random_21.txt AC 1 ms 3500 KiB
01_random_22.txt AC 1 ms 3488 KiB
02_handmade_23.txt AC 45 ms 4796 KiB
02_handmade_24.txt AC 16 ms 3848 KiB
02_handmade_25.txt AC 36 ms 4676 KiB
02_handmade_26.txt AC 5 ms 3496 KiB
02_handmade_27.txt AC 51 ms 4884 KiB
02_handmade_28.txt AC 36 ms 5184 KiB
02_handmade_29.txt AC 24 ms 5032 KiB