結果

問題 No.2710 How many more?
ユーザー BBhorseBBhorse
提出日時 2024-03-31 15:04:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 173,408 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 15:04:58
合計ジャッジ時間 5,651 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 232 ms
6,548 KB
testcase_03 AC 135 ms
6,548 KB
testcase_04 AC 98 ms
6,548 KB
testcase_05 AC 76 ms
6,548 KB
testcase_06 AC 85 ms
6,548 KB
testcase_07 AC 101 ms
6,548 KB
testcase_08 AC 75 ms
6,548 KB
testcase_09 AC 192 ms
6,548 KB
testcase_10 AC 111 ms
6,548 KB
testcase_11 AC 183 ms
6,548 KB
testcase_12 AC 254 ms
6,548 KB
testcase_13 AC 272 ms
6,548 KB
testcase_14 AC 272 ms
6,548 KB
testcase_15 AC 272 ms
6,548 KB
testcase_16 AC 270 ms
6,548 KB
testcase_17 AC 271 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll=long long;
#define rep(i,s,n) for (ll i = (s); i < (n); i++)
using namespace std;
using Graph = vector<vector<ll>>;
ll MOD=998244353;
const ll INF=1e18;


int main(){
  ll N,Q;
  cin>>N>>Q;
  vector<ll> A(N);
  vector<ll> Z(N);
  rep(i,0,N){
    cin>>A[i];
    Z[i]=A[i];
  }
  sort(A.begin(),A.end());
  rep(i,0,Q){
    ll x,y;
    cin>>x>>y;
    x--;y--;
    auto itrX=lower_bound(A.begin(),A.end(),Z[x]);
    ll idxX=distance(A.begin(),itrX);
    auto itrY=upper_bound(A.begin(),A.end(),Z[y]);
    itrY--;
    ll idxY=distance(A.begin(),itrY);

    cout<<max((ll)0,idxX-idxY-1)<<endl;

  }
}
0