結果

問題 No.2710 How many more?
ユーザー futamegawafutamegawa
提出日時 2024-03-31 14:07:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 3,129 ms
コンパイル使用メモリ 255,484 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-03-31 14:08:00
合計ジャッジ時間 8,651 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 307 ms
10,496 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 106 ms
6,676 KB
testcase_08 AC 92 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 226 ms
7,808 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using llu = long long unsigned;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n), x(q), y(q);
    for (auto &x : a) { cin >> x; }
    for (int i=0; i<q; ++i) {
        cin >> x[i] >> y[i];
    }

    map<int, int> data;
    for (int i=0; i<n; ++i) {
        data[a[i]] = i+1;
    }
    map<int, int> data2;
    int count = 1;
    for (auto x : data) {
        data2[x.second] = count;
        count++;
    }

    //for (auto x : data2) { cout << x.first << " " << x.second << endl; }

    vector<int> ret;
    for (int i=0; i<q; ++i) {
        if (data2[x[i]] <= data2[y[i]]) {
            ret.push_back(0);
            continue;
        }
        ret.push_back(data2[x[i]]-data2[y[i]]-1);
    }

    for (auto x : ret) { cout << x << endl; }
    return 0;
}
0