結果
| 問題 |
No.2710 How many more?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 17:23:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 434 bytes |
| コンパイル時間 | 680 ms |
| コンパイル使用メモリ | 69,240 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 09:27:33 |
| 合計ジャッジ時間 | 3,119 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
int N,Q;
int A[1<<17],B[1<<17];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>Q;
for(int i=0;i<N;i++)
{
cin>>A[i];
B[i]=A[i];
}
sort(B,B+N);
for(;Q--;)
{
int x,y;cin>>x>>y;
int l=A[y-1],r=A[x-1];
if(l>=r)cout<<"0\n";
else
{
l=upper_bound(B,B+N,l)-B;
r=lower_bound(B,B+N,r)-B;
cout<<r-l<<"\n";
}
}
}