結果

問題 No.2710 How many more?
ユーザー RYOH2718RYOH2718
提出日時 2024-03-31 21:10:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 2,384 ms
コンパイル使用メモリ 207,404 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 21:11:00
合計ジャッジ時間 7,189 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 237 ms
6,676 KB
testcase_03 AC 139 ms
6,676 KB
testcase_04 AC 101 ms
6,676 KB
testcase_05 AC 77 ms
6,676 KB
testcase_06 AC 86 ms
6,676 KB
testcase_07 AC 103 ms
6,676 KB
testcase_08 AC 75 ms
6,676 KB
testcase_09 AC 201 ms
6,676 KB
testcase_10 AC 114 ms
6,676 KB
testcase_11 AC 191 ms
6,676 KB
testcase_12 AC 260 ms
6,676 KB
testcase_13 AC 284 ms
6,676 KB
testcase_14 AC 283 ms
6,676 KB
testcase_15 AC 282 ms
6,676 KB
testcase_16 AC 324 ms
6,676 KB
testcase_17 AC 285 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define inner(y) (0 <= y && y < N) 

typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;

#ifdef USE_MY_LIBS
#include "mylib/all"
#endif

// 配列の標準出力ユーティリティ(デバッグ用)
#ifdef _MY_DEBUG
template<typename T>
void checkArray1D(T& a, int width = 10) {
    ll nrow = (ll)a.size();
    for (int i = 0; i < nrow; i++) {
        cout << setw(width) << a[i] << " ";
    }
    cout << endl;
}

template<typename T>
void checkArray2D(T& a, int width = 10) {
    ll nrow = (ll)a.size();
    ll ncol = (ll)a[0].size();
    for (int i = 0; i < nrow; i++) {
        for (int j = 0; j < ncol; j++) {
            cout << setw(width) << a[i][j] << " ";
        }
        cout << endl;
    }
}

#endif

int main() {
    int N, Q; cin >> N >> Q;
    vector<ll> A(N);
    vector<ll> As(N);
    rep(i, N) {
        cin >> A[i];
        As[i] = A[i];
    }
    sort(As.begin(), As.end());
    rep(i, Q) {
        int x, y; cin >> x >> y;
        x--; y--;
        int r = lower_bound(As.begin(), As.end(), A[x]) - As.begin();
        int l = upper_bound(As.begin(), As.end(), A[y]) - As.begin();
        cout << max(r - l, 0) << endl;
    }
    return 0;
}
0