結果

問題 No.2710 How many more?
ユーザー tobbietobbie
提出日時 2024-04-27 18:19:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 175,340 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 18:19:18
合計ジャッジ時間 6,002 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 190 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 85 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 81 ms
6,940 KB
testcase_08 AC 60 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 172 ms
6,944 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,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<pii> A(N);
  rep(i, N) {
    int Ai;
    cin >> Ai;
    A[i] = {Ai, i};
  }
  sort(A.begin(), A.end());
  vector<int> B(N);
  rep(i, N)
    B[A[i].second] = i;
  rep(i, Q) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    int dif = B[x] - B[y] - 1;
    if (dif < 0) dif = 0;
    cout << dif << endl;
  }
  return 0;
}
0