結果
| 問題 |
No.2710 How many more?
|
| コンテスト | |
| ユーザー |
kekenx
|
| 提出日時 | 2024-05-26 21:35:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 571 bytes |
| コンパイル時間 | 828 ms |
| コンパイル使用メモリ | 82,968 KB |
| 最終ジャッジ日時 | 2025-02-21 16:50:11 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 11 |
ソースコード
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, Q; cin >> N >> Q;
vector<pair<int, int>> A(N);
for (int i = 0; i < N; i++) {
int a; cin >> a;
A[i] = make_pair(a, i);
}
vector<int> b(N);
sort(A.rbegin(), A.rend());
for (int i = 0; i < N; i++) {
b[A[i].second] = i;
}
while (Q--) {
int x, y; cin >> x >> y;
x--; y--;
int frm = b[x], to = b[y];
if (frm >= to)
cout << 0 << endl;
else
cout << to - frm - 1 << endl;
}
return 0;
}
kekenx