結果

問題 No.2710 How many more?
ユーザー mitani
提出日時 2024-03-31 14:40:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 3,622 ms
コンパイル使用メモリ 241,892 KB
実行使用メモリ 10,456 KB
最終ジャッジ日時 2024-09-30 19:49:26
合計ジャッジ時間 7,650 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#include <atcoder/all>
using namespace atcoder;
//using mint=static_modint<998244353>;
using mint=static_modint<1000000007>;

ll n,q;
vector<int> a;

int main(){
	cin>>n>>q;
    a.resize(n);
    rep(i,n)cin>>a[i];
    priority_queue<P,vector<P>,greater<P>> pq;
    rep(i,n)pq.push({a[i],i});
    vector<int> pos(n);
    int cnt=0;
    map<int,int> mp;
    while(!pq.empty()){
        P p=pq.top();pq.pop();
        pos[p.second]=cnt;
        cnt++;
        mp[p.first]++;
    }

    rep(i,q){
        int x,y;cin>>x>>y;
        x--;y--;
        cout<<max(0,pos[x]-pos[y]-mp[a[x]])<<endl;
    }
}
0