結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-31 15:19:00 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 74 ms / 2,000 ms | 
| コード長 | 485 bytes | 
| コンパイル時間 | 1,350 ms | 
| コンパイル使用メモリ | 109,144 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-09-30 20:33:09 | 
| 合計ジャッジ時間 | 3,307 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    int n, q;
    std::cin >> n >> q;
    std::vector<int> a(n), b;
    for(auto &el: a) {
        std::cin >> el;
    }
    b = a;
    std::ranges::sort(b);
    while(q--) {
        int x, y;
        std::cin >> x >> y;
        x--, y--;
        std::cout << std::max(0L, std::ranges::lower_bound(b, a[x]) - std::ranges::upper_bound(b, a[y])) << '\n';
    }
}
            
            
            
        