結果

問題 No.2710 How many more?
ユーザー k82bk82b
提出日時 2024-03-31 14:04:32
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 202,476 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2024-03-31 14:04:44
合計ジャッジ時間 4,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 133 ms
6,688 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 52 ms
6,548 KB
testcase_08 AC 43 ms
6,548 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 104 ms
6,548 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std, core.bitop;
bool chmin(T)(ref T SE, T MI) { if (SE > MI) { SE = MI; return true; } else { return false; } }
bool chmax(T)(ref T SE, T MI) { if (SE < MI) { SE = MI; return true; } else { return false; } }
int lowerBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] < MI ? lo : hi) = mid; } return hi; }
int upperBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] > MI ? hi : lo) = mid; } return hi; }
void main() {
	int N, Q;
	readf("%s %s\n", N, Q);
	auto A = readln.chomp.split.to!(int[]);
	auto B = A.dup;
	B = B.sort.uniq.array;
	foreach (i; 0 .. Q) {
		int x, y;
		readf("%s %s\n", x, y);
		int idx = B.lowerBound(A[--x]);
		int idy = B.lowerBound(A[--y]);
		max(0, idx - idy - 1).writeln;
	}
}
0