結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-07-04 03:29:11 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 856 bytes | 
| コンパイル時間 | 5,277 ms | 
| コンパイル使用メモリ | 317,024 KB | 
| 実行使用メモリ | 13,568 KB | 
| 最終ジャッジ日時 | 2024-07-04 03:29:34 | 
| 合計ジャッジ時間 | 10,154 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 WA * 12 | 
ソースコード
#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;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q; cin >> N >> Q;
    vector<int> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    vector<int> B(N); copy(A.begin(), A.end(), B.begin());
    sort(B.begin(), B.end()); B.erase(unique(B.begin(), B.end()), B.end());
    map<int, int> ord; for(int i = 0; i < int(B.size()); i++) ord[B[i]] = i;
    map<int, int> idx; for(int i = 0; i < N; i++) idx[i] = ord[A[i]];
    while(Q--) {
        int x, y; cin >> x >> y;
        x--; y--;
        if(idx[x] <= idx[y]) cout << 0 << endl;
        else {
            cout << (idx[x] - idx[y] - 1) << endl;
        }
    }
}
            
            
            
        