結果
| 問題 |
No.2710 How many more?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-28 23:22:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 244 ms / 2,000 ms |
| コード長 | 498 bytes |
| コンパイル時間 | 3,427 ms |
| コンパイル使用メモリ | 252,968 KB |
| 最終ジャッジ日時 | 2025-02-20 14:22:54 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#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;
}
}