結果

問題 No.2710 How many more?
ユーザー ryota2357ryota2357
提出日時 2024-03-31 12:00:56
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 1,276 ms
コンパイル使用メモリ 121,088 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 12:01:03
合計ジャッジ時間 6,258 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 226 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 83 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 98 ms
6,676 KB
testcase_08 AC 73 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 178 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, q;
    cin >> n; cin >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) { cin >> a[i]; }
    assert(2 <= n && n <= 100000);
    assert(1 <= q && q <= 100000);
    for (int i = 0; i < n; ++i) { assert(1 <= a[i] && a[i] <= 1000000000); }

    vector<int> b(a);
    sort(b.begin(), b.end());
    while (q--) {
        int x, y;
        cin >> x >> y;
        int dist_x = a[x - 1];
        int dist_y = a[y - 1];
        int num_x = lower_bound(b.begin(), b.end(), dist_x) - b.begin();
        int num_y = lower_bound(b.begin(), b.end(), dist_y) - b.begin();
        int ans = num_x - num_y - 1;
        cout << max(ans, 0) << endl;
    }
    return 0;
}
0