結果
問題 | No.2710 How many more? |
ユーザー | Iroha_3856 |
提出日時 | 2024-03-31 13:54:41 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 4,384 bytes |
コンパイル時間 | 5,318 ms |
コンパイル使用メモリ | 331,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 18:37:22 |
合計ジャッジ時間 | 8,505 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 174 ms
5,248 KB |
testcase_03 | AC | 87 ms
5,248 KB |
testcase_04 | AC | 57 ms
5,248 KB |
testcase_05 | AC | 54 ms
5,248 KB |
testcase_06 | AC | 49 ms
5,248 KB |
testcase_07 | AC | 71 ms
5,248 KB |
testcase_08 | AC | 50 ms
5,248 KB |
testcase_09 | AC | 131 ms
5,248 KB |
testcase_10 | AC | 71 ms
5,248 KB |
testcase_11 | AC | 122 ms
5,248 KB |
testcase_12 | AC | 161 ms
5,248 KB |
testcase_13 | AC | 171 ms
5,248 KB |
testcase_14 | AC | 172 ms
5,248 KB |
testcase_15 | AC | 172 ms
5,248 KB |
testcase_16 | AC | 170 ms
5,248 KB |
testcase_17 | AC | 173 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
ソースコード
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; //AtCoder-Library #if __has_include(<atcoder/all>) #include<atcoder/all> using namespace atcoder; using mint = atcoder::modint998244353; #endif //PBDS-tree #if __has_include(<ext/pb_ds/assoc_container.hpp>) #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/tag_and_trait.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //tree.find_by_order(k) = tree[k] (0-indexed) //tree.order_of_key(k) = tree.lower_bound(k) - tree.begin() //Note: Can only be used for non-multiple sets. #endif #define vec vector #define ll long long #define ull unsigned long long #define vi vec<int> #define vll vec<ll> #define vb vec<bool> #define vvi vec<vi> #define vvll vec<vll> #define vvb vec<vb> #define vvvi vec<vvi> #define vvvll vec<vvll> #define vvvb vec<vvb> #define pii pair<int, int> #define pll pair<ll, ll> #define pli pair<ll, int> #define pq priority_queue template<class T> using spq = priority_queue<T, vector<T>, greater<T>>; #define eb emplace_back #define pb push_back #define spa " " #define all(x) (x).begin(), (x).end() #define rep(i, l, r) for (int i=(int)(l); i<(int)(r); i++) #define REP(i, l, r) for (int i=(int)(l); i<=(int)(r); i++) #define siz(x) (int)x.size() template<class T>bool chmax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, T b) { if (b<a) { a=b; return 1; } return 0; } //Slice(A, l, r) = A[l, r) template<class T> vector<T> Slice(vector<T> A, int l, int r) { assert(0 <= l && l < (int)A.size()); assert(0 <= r && r <= (int)A.size()); vector<T> ret; for (int i = l; i<r; i++) ret.push_back(A[i]); return ret; } //Slice(S, l, r) = S[l, r) string Slice(string s, int l, int r) { assert(0 <= l && l < (int)s.size()); assert(0 <= r && r <= (int)s.size()); string ret; for (int i = l; i<r; i++) ret += s[i]; return ret; } ll Ceil(ll x, ll y) { assert(y != 0); if ((x >= 0) == (y >= 0)) { return (abs(x) + abs(y)-1)/abs(y); } else { return -(abs(x)/abs(y)); } } ll Floor(ll x, ll y) { assert(y != 0); if ((x >= 0) == (y >= 0)) { return abs(x)/abs(y); } else { return -((abs(x) + abs(y)-1)/abs(y)); } } template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for(auto &x : v) { is >> x; } return is; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int)v.size(); i++) { if(i != (int)v.size() - 1) os << v[i] << " "; else os << v[i]; } return os; } template<class T> void print(T A, bool f = true) { cerr << A; if (f) cerr << endl; } template<class T, class U> void print(pair<T, U> A, bool f = true) { cerr << "{" << A.first << ", " << A.second << "}"; if (f) cerr << endl; } template<class T> void print(vector<T> A, bool f = true) { cerr << "{"; for (int i = 0; i<(int)A.size(); i++) { print(A[i], false); if (i+1 != (int)A.size()) cerr << ", "; } cerr << "}"; if (f) cerr << endl; } #define debug(x) cerr << #x << " = "; print(x) #define debug2(x) cerr << #x << " = "; print(x, false) struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); } } iosetup; struct Edge { int to; int cost; Edge(int to, int cost) : to(to), cost(cost) {} }; const int mod1 = 998244353; const int mod2 = 1000000007; const int inf = 1000010000; const ll INF = 1LL<<60; int main() { int N, Q; cin >> N >> Q; vector<int> A(N); rep(i, 0, N) cin >> A[i]; auto B = A; sort(B.begin(), B.end()); rep(i, 0, Q) { int x, y; cin >> x >> y; x--; y--; int ans = lower_bound(B.begin(), B.end(), A[x]) - lower_bound(B.begin(), B.end(), A[y] + 1); cout << max(ans, 0) << endl; } }