結果

問題 No.905 Sorted?
ユーザー kuhakukuhaku
提出日時 2019-10-11 22:23:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 1,438 ms
コンパイル使用メモリ 165,872 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2023-08-16 18:33:01
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 191 ms
4,532 KB
testcase_09 AC 115 ms
4,440 KB
testcase_10 AC 186 ms
5,556 KB
testcase_11 AC 177 ms
5,216 KB
testcase_12 AC 202 ms
4,992 KB
testcase_13 AC 215 ms
6,016 KB
testcase_14 AC 215 ms
5,716 KB
testcase_15 AC 199 ms
5,696 KB
testcase_16 AC 219 ms
5,880 KB
testcase_17 AC 210 ms
5,692 KB
testcase_18 AC 159 ms
5,780 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

int main(void){
	int n;
	cin >> n;

	ll a[n];
	ll asc[n];
	ll desc[n];
	REP(i, n){
		cin >> a[i];
	}

	REP(i, n){
		if(!i) asc[i] = 0;
		if(a[i] >= a[i-1]) asc[i] = asc[i-1]+1;
		else asc[i] = 0;
	}
	REP(i, n){
		if(!i) desc[i] = 0;
		if(a[i] <= a[i-1]) desc[i] = desc[i-1]+1;
		else desc[i] = 0;
	}

	int q;
	cin >> q;
	REP(i, q){
		int l, r;
		cin >> l >> r;
		if(asc[r] >= r-l) cout << 1 << ' ';
		else cout << 0 << ' ';
		if(desc[r] >= r-l) cout << 1 << endl;
		else cout << 0 << endl;
	}

	return 0;
}
0