結果

問題 No.2710 How many more?
ユーザー manabeaimanabeai
提出日時 2024-03-31 14:25:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 1,079 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 214,544 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-03-31 14:25:37
合計ジャッジ時間 7,684 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 348 ms
7,552 KB
testcase_03 AC 196 ms
7,808 KB
testcase_04 AC 150 ms
9,856 KB
testcase_05 AC 106 ms
6,676 KB
testcase_06 AC 125 ms
8,960 KB
testcase_07 AC 119 ms
6,676 KB
testcase_08 AC 95 ms
6,676 KB
testcase_09 AC 281 ms
8,704 KB
testcase_10 AC 153 ms
6,676 KB
testcase_11 AC 266 ms
6,676 KB
testcase_12 AC 374 ms
9,728 KB
testcase_13 AC 413 ms
10,368 KB
testcase_14 AC 432 ms
10,368 KB
testcase_15 AC 400 ms
10,368 KB
testcase_16 AC 405 ms
10,368 KB
testcase_17 AC 439 ms
10,368 KB
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll is_ika(vector<ll> &A, ll x) {
    ll under_mid = upper_bound(A.begin(), A.end(), x) - A.begin();
    return under_mid;
}

ll is_ijo(vector<ll> &A, ll x) {
    ll upper_mid = A.end() - lower_bound(A.begin(), A.end(), x);
    return upper_mid;
}

ll is_koe(vector<ll> &A, ll x) {
    ll upper_mid = A.end() - upper_bound(A.begin(), A.end(), x);
    return upper_mid;
}

ll is_miman(vector<ll> &A, ll x) {
    ll under_mid = lower_bound(A.begin(), A.end(), x) - A.begin();
    return under_mid;
}
void solve() {
    ll n,q; 
    cin >> n >> q;

    vector<ll> A(n);
    for (ll i = 0; i < n; ++i) cin >> A[i];

    map<ll,ll> juni;
    for (ll i = 0; i < n; ++i) {
        juni[i]=A[i];
    }

    sort(A.begin(), A.end());


    for (ll qqq = 0; qqq < q; ++qqq) {
        ll kyo = 0;

        ll x,y;
        cin >> x >> y;
        --x, --y; 

        ll xm = is_miman(A,juni[x]);
        ll ym = is_ika(A,juni[y]);

        cout << max((ll)0,xm-ym) << endl;

    }
}

int main() {
    solve();
    return 0;
}
0