結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  forest3 | 
| 提出日時 | 2024-07-12 15:34:17 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 260 ms / 2,000 ms | 
| コード長 | 448 bytes | 
| コンパイル時間 | 1,771 ms | 
| コンパイル使用メモリ | 174,092 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-12 15:34:25 | 
| 合計ジャッジ時間 | 6,565 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
int main() {
	int N, Q;
	cin >> N >> Q;
	vector<int> a(N), b;
	rep(i, N) cin >> a[i];
	b = a;
	sort(b.begin(), b.end());
	rep(i, Q) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		int ans = 0;
		if(a[x] > a[y]) {
			ans = lower_bound(b.begin(), b.end(), a[x]) - upper_bound(b.begin(), b.end(), a[y]);
		}
		cout << ans << endl;
	}
}
            
            
            
        