結果

問題 No.2710 How many more?
ユーザー kekenx
提出日時 2024-05-26 21:47:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 79,512 KB
最終ジャッジ日時 2025-02-21 16:50:18
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N, Q; cin >> N >> Q;

  vector<int> A(N);
  for (int &a: A) {
    cin >> a;
    a = -a;
  }
  vector<int> b = A;
  sort(b.begin(), b.end());

  while (Q--) {
    int x, y; cin>> x>> y;
    x--; y--;
    int a1 = A[x], a2 = A[y];
    int frm = lower_bound(b.begin(), b.end(), a1) - b.begin();
    int to = lower_bound(b.begin(), b.end(), a2) - b.begin();
    if (frm >= to)
      cout << 0 << endl;
    else
      cout << to - frm - 1 << endl;
  } 
  return 0;
}
  

0