結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  srjywrdnprkt | 
| 提出日時 | 2024-04-03 12:33:18 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 193 ms / 2,000 ms | 
| コード長 | 537 bytes | 
| コンパイル時間 | 2,107 ms | 
| コンパイル使用メモリ | 199,304 KB | 
| 最終ジャッジ日時 | 2025-02-20 19:51:31 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int N, Q, x, y;
    cin >> N >> Q;
    vector<int> A(N), B;
    for (int i=0; i<N; i++) cin >> A[i];
    B = A;
    sort(B.begin(), B.end());
    for (int i=0; i<Q; i++){
        cin >> x >> y;
        x--; y--;
        if (A[y] >= A[x]) cout << 0 << endl;
        else cout << lower_bound(B.begin(), B.end(), A[x]) - upper_bound(B.begin(), B.end(), A[y]) << endl;
    }
    return 0;
}
            
            
            
        