結果

問題 No.2710 How many more?
ユーザー BBhorseBBhorse
提出日時 2024-03-31 14:58:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 173,156 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:58:06
合計ジャッジ時間 5,904 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 235 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 76 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 101 ms
6,676 KB
testcase_08 AC 75 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 186 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,676 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=lower_bound(A.begin(),A.end(),Z[y]);
    ll idxY=distance(A.begin(),itrY);

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

  }
}
0