結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2025-09-04 23:23:45 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 302 ms / 2,000 ms | 
| コード長 | 440 bytes | 
| コンパイル時間 | 2,048 ms | 
| コンパイル使用メモリ | 197,928 KB | 
| 実行使用メモリ | 8,172 KB | 
| 最終ジャッジ日時 | 2025-09-04 23:23:53 | 
| 合計ジャッジ時間 | 7,662 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long n,q,a[100000001],b[100000001],x,y,l,r;
int main() {
    cin>>n>>q;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    while(q--){
        cin>>x>>y;
        if(a[x]<=a[y]) cout<<0<<"\n";
        else {
            l=upper_bound(b+1,b+n+1,a[y])-b;
            r=lower_bound(b+1,b+n+1,a[x])-b;
            cout<<r-l<<"\n";
        }
    }
}
            
            
            
        