結果

問題 No.2710 How many more?
ユーザー Nafmo2
提出日時 2024-01-22 19:35:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 4,215 ms
コンパイル使用メモリ 252,392 KB
最終ジャッジ日時 2025-02-18 22:09:38
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main() {
  int ans = 0;
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  auto B = A;
  sort(B.begin(), B.end());
  while (Q--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    int r = lower_bound(B.begin(), B.end(), A[x]) - B.begin() ;
    int l = upper_bound(B.begin(), B.end(), A[y]) - B.begin();
    cout<< max(r-l,0) << endl;
  }

}
0