結果

問題 No.2710 How many more?
ユーザー startcppstartcpp
提出日時 2024-03-31 13:37:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 13:37:52
合計ジャッジ時間 4,890 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 234 ms
6,548 KB
testcase_03 AC 136 ms
6,548 KB
testcase_04 AC 99 ms
6,548 KB
testcase_05 AC 78 ms
6,548 KB
testcase_06 AC 85 ms
6,548 KB
testcase_07 AC 101 ms
6,548 KB
testcase_08 AC 74 ms
6,548 KB
testcase_09 AC 194 ms
6,548 KB
testcase_10 AC 112 ms
6,548 KB
testcase_11 AC 186 ms
6,548 KB
testcase_12 AC 262 ms
6,548 KB
testcase_13 AC 278 ms
6,548 KB
testcase_14 AC 273 ms
6,548 KB
testcase_15 AC 273 ms
6,548 KB
testcase_16 AC 272 ms
6,548 KB
testcase_17 AC 271 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, q;
int a[100000];
int sa[100000];
int x, y;

signed main() {
	int i;

	cin >> n >> q;
	rep(i, n) { cin >> a[i]; a[i] = -a[i]; }
	rep(i, n) sa[i] = a[i];
	sort(sa, sa + n);

	rep(i, q) {
		cin >> x >> y;
		x--; y--;
		int l = upper_bound(sa, sa + n, a[x]) - sa;
		int r = lower_bound(sa, sa + n, a[y]) - sa;
		cout << max(0LL, r - l) << endl;
	}
	return 0;
}
0