結果

問題 No.2710 How many more?
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-03-31 14:12:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 207,768 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 14:12:43
合計ジャッジ時間 6,168 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 233 ms
6,548 KB
testcase_03 AC 137 ms
6,548 KB
testcase_04 AC 99 ms
6,548 KB
testcase_05 AC 77 ms
6,548 KB
testcase_06 AC 86 ms
6,548 KB
testcase_07 AC 101 ms
6,548 KB
testcase_08 AC 75 ms
6,548 KB
testcase_09 AC 195 ms
6,548 KB
testcase_10 AC 114 ms
6,548 KB
testcase_11 AC 187 ms
6,548 KB
testcase_12 AC 256 ms
6,548 KB
testcase_13 AC 274 ms
6,548 KB
testcase_14 AC 274 ms
6,548 KB
testcase_15 AC 275 ms
6,548 KB
testcase_16 AC 273 ms
6,548 KB
testcase_17 AC 274 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b = a;
    sort(b.begin(), b.end());
    //b.erase(unique(b.begin(), b.end()), b.end());
    while (q--) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        int ix = lower_bound(b.begin(), b.end(), a[x]) - b.begin();
        int iy = upper_bound(b.begin(), b.end(), a[y]) - b.begin();
        iy--;
        int ans = max(0, ix - iy - 1);
        cout << ans << endl;
    }
}
0