結果

問題 No.2710 How many more?
ユーザー mitanimitani
提出日時 2024-03-31 14:40:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 4,382 ms
コンパイル使用メモリ 241,220 KB
実行使用メモリ 10,404 KB
最終ジャッジ日時 2024-03-31 14:40:52
合計ジャッジ時間 8,583 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 258 ms
7,476 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 92 ms
6,676 KB
testcase_06 AC 117 ms
8,964 KB
testcase_07 AC 100 ms
6,548 KB
testcase_08 AC 81 ms
6,548 KB
testcase_09 WA -
testcase_10 AC 126 ms
6,548 KB
testcase_11 AC 199 ms
6,548 KB
testcase_12 WA -
testcase_13 AC 329 ms
10,404 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

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