結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-04-01 02:00:39 | 
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 185 ms / 2,000 ms | 
| コード長 | 705 bytes | 
| コンパイル時間 | 23,345 ms | 
| コンパイル使用メモリ | 356,456 KB | 
| 最終ジャッジ日時 | 2025-02-20 18:38:03 | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using P=pair<ll,ll>;
void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}
int main(){
  IO();
  ll n,q;
  cin>>n>>q;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  vector<ll> b=a;
  sort(b.begin(),b.end());
  while(q--){
    ll x,y;
    cin>>x>>y;
    x--;
    y--;
    if(a[y]>=a[x]){
      cout<<0<<endl;
    }else{
      ll l=upper_bound(b.begin(),b.end(),a[y])-b.begin();
      ll r=lower_bound(b.begin(),b.end(),a[x])-b.begin();
      cout<<r-l<<endl;
    }
  }
}
            
            
            
        