結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-07-04 16:12:26 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 361 ms / 2,000 ms | 
| コード長 | 781 bytes | 
| コンパイル時間 | 6,227 ms | 
| コンパイル使用メモリ | 317,868 KB | 
| 実行使用メモリ | 10,240 KB | 
| 最終ジャッジ日時 | 2024-07-04 16:12:38 | 
| 合計ジャッジ時間 | 11,810 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#ifdef LOCAL
#include <algo/debug.h>
#else
#define debug(...) void(0)
#endif
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q; cin >> N >> Q;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    map<ll, ll> MP; for(int i = 0; i < N; i++) MP[i + 1] = A[i]; 
    sort(A.begin(), A.end());
    while(Q--) {
        ll x, y; cin >> x >> y;
        ll l = distance(A.begin(), lower_bound(A.begin(), A.end(), MP[x]));
        ll r = distance(A.begin(), upper_bound(A.begin(), A.end(), MP[y]));
        if(l < r) cout << 0 << endl;
        else cout << l - r << endl;
    }
}
            
            
            
        