結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-31 13:43:18 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 53 ms / 2,000 ms | 
| コード長 | 434 bytes | 
| コンパイル時間 | 788 ms | 
| コンパイル使用メモリ | 69,376 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-09-30 18:17:28 | 
| 合計ジャッジ時間 | 2,359 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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";
		}
	}
}
            
            
            
        