結果
| 問題 |
No.2710 How many more?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-01 20:33:49 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 325 ms / 2,000 ms |
| コード長 | 781 bytes |
| コンパイル時間 | 4,129 ms |
| コンパイル使用メモリ | 335,444 KB |
| 実行使用メモリ | 12,992 KB |
| 最終ジャッジ日時 | 2024-11-01 20:33:59 |
| 合計ジャッジ時間 | 9,105 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include <bits/extc++.h>
int main() {
using namespace std;
unsigned N, Q;
cin >> N >> Q;
vector<unsigned> A(N);
for (auto &a : A)
cin >> a;
unordered_map<unsigned, unsigned> value_to_rank_lower, value_to_rank_upper;
{
vector<unsigned> tmp(A);
ranges::sort(tmp);
for (unsigned i{}; i < size(tmp); i++) {
value_to_rank_upper[tmp[i]] = i;
if (!value_to_rank_lower.contains(tmp[i]))
value_to_rank_lower[tmp[i]] = i;
}
}
for (unsigned i{}; i < Q; i++) {
unsigned x, y;
cin >> x >> y;
--x;
--y;
cout << (value_to_rank_lower[A[x]] - min(value_to_rank_upper[A[y]] + 1, value_to_rank_lower[A[x]])) << endl;
}
return 0;
}