結果
問題 | No.2710 How many more? |
ユーザー |
![]() |
提出日時 | 2024-11-01 21:15:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 467 ms / 2,000 ms |
コード長 | 688 bytes |
コンパイル時間 | 6,500 ms |
コンパイル使用メモリ | 338,476 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2024-11-01 21:15:16 |
合計ジャッジ時間 | 12,614 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; const ll INF=9e18; int main() { ll N,Q; cin>>N>>Q; vector<ll> A (N); map<ll,ll>hito; for (ll a = 0; a < N; a++){ cin>>A[a]; hito[a]=A[a]; } sort(A.begin(),A.end()); for (ll a = 0; a < Q; a++){ ll x,y; cin>>x>>y; x--;y--; ll x_doko=lower_bound(A.begin(),A.end(),hito[x])-A.begin(); ll y_doko=upper_bound(A.begin(),A.end(),hito[y])-A.begin()-1; //cout<<"x,y"<<x_doko<<' '<<y_doko<<endl; cout<<max(0LL,x_doko-y_doko-1)<<endl; } }