結果
問題 |
No.2710 How many more?
|
ユーザー |
|
提出日時 | 2024-03-31 12:00:56 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 785 bytes |
コンパイル時間 | 1,184 ms |
コンパイル使用メモリ | 131,944 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-30 17:54:37 |
合計ジャッジ時間 | 5,464 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 11 |
ソースコード
#include <algorithm> #include <cassert> #include <iostream> #include <vector> using namespace std; int main() { int n, q; cin >> n; cin >> q; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } assert(2 <= n && n <= 100000); assert(1 <= q && q <= 100000); for (int i = 0; i < n; ++i) { assert(1 <= a[i] && a[i] <= 1000000000); } vector<int> b(a); sort(b.begin(), b.end()); while (q--) { int x, y; cin >> x >> y; int dist_x = a[x - 1]; int dist_y = a[y - 1]; int num_x = lower_bound(b.begin(), b.end(), dist_x) - b.begin(); int num_y = lower_bound(b.begin(), b.end(), dist_y) - b.begin(); int ans = num_x - num_y - 1; cout << max(ans, 0) << endl; } return 0; }