結果

問題 No.905 Sorted?
ユーザー QCFiumQCFium
提出日時 2019-10-11 21:45:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 165,012 KB
実行使用メモリ 5,096 KB
最終ジャッジ日時 2023-08-16 17:32:51
合計ジャッジ時間 3,967 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,388 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 60 ms
4,388 KB
testcase_09 AC 33 ms
4,376 KB
testcase_10 AC 74 ms
4,980 KB
testcase_11 AC 49 ms
4,708 KB
testcase_12 AC 53 ms
4,688 KB
testcase_13 AC 89 ms
5,072 KB
testcase_14 AC 89 ms
5,076 KB
testcase_15 AC 51 ms
5,096 KB
testcase_16 AC 62 ms
5,088 KB
testcase_17 AC 60 ms
5,004 KB
testcase_18 AC 51 ms
5,076 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int64_t a[n];
	for (auto &i : a) std::cin >> i;
	int down[n];
	int up[n];
	down[0] = up[0] = 0;
	for (int i = 1; i < n; i++) {
		up[i] = (a[i - 1] < a[i]);
		down[i] = (a[i - 1] > a[i]);
	}
	for (int i = 0; i + 1 < n; i++) down[i + 1] += down[i], up[i + 1] += up[i];
	int q = ri();
	for (int i = 0; i < q; i++) {
		int l = ri();
		int r = ri();
		printf("%d %d\n", !(down[r] - down[l]), !(up[r] - up[l]));
	}
	return 0;
}
0