結果
| 問題 |
No.2710 How many more?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 14:22:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 458 bytes |
| コンパイル時間 | 2,195 ms |
| コンパイル使用メモリ | 198,004 KB |
| 最終ジャッジ日時 | 2025-02-20 17:11:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,Q;
cin>>N>>Q;
vector A(N,0);
for(int &i:A)cin>>i,i*=-1;
auto B=A;
sort(B.begin(),B.end());
while(Q--){
int X,Y;
cin>>X>>Y;
--X,--Y;
int ans=(int)(lower_bound(B.begin(),B.end(),A[Y])-B.begin())-(int)(upper_bound(B.begin(),B.end(),A[X])-B.begin());
ans=max(ans,0);
cout<<ans<<'\n';
}
}