結果
問題 | No.2710 How many more? |
ユーザー | startcpp |
提出日時 | 2024-03-31 13:37:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 239 ms / 2,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 888 ms |
コンパイル使用メモリ | 87,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 18:10:04 |
合計ジャッジ時間 | 4,640 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <tuple> #include <cstdio> #include <cmath> #include <cassert> #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; int n, q; int a[100000]; int sa[100000]; int x, y; signed main() { int i; cin >> n >> q; rep(i, n) { cin >> a[i]; a[i] = -a[i]; } rep(i, n) sa[i] = a[i]; sort(sa, sa + n); rep(i, q) { cin >> x >> y; x--; y--; int l = upper_bound(sa, sa + n, a[x]) - sa; int r = lower_bound(sa, sa + n, a[y]) - sa; cout << max(0LL, r - l) << endl; } return 0; }