結果

問題 No.905 Sorted?
ユーザー KKT89KKT89
提出日時 2019-10-11 22:07:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 73,012 KB
実行使用メモリ 4,684 KB
最終ジャッジ日時 2023-08-16 18:02:05
合計ジャッジ時間 3,924 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 141 ms
4,384 KB
testcase_09 AC 86 ms
4,380 KB
testcase_10 AC 121 ms
4,420 KB
testcase_11 AC 133 ms
4,384 KB
testcase_12 AC 157 ms
4,380 KB
testcase_13 AC 139 ms
4,416 KB
testcase_14 AC 140 ms
4,624 KB
testcase_15 AC 161 ms
4,672 KB
testcase_16 AC 162 ms
4,684 KB
testcase_17 AC 161 ms
4,496 KB
testcase_18 AC 119 ms
4,500 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int mi[100100];
int ma[100100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int right=0;
	for(int i=0;i<n-1;i++){
		if(a[i]>=a[i+1]){
			int cp=i;
			while(cp<n-1&&a[cp]>=a[cp+1]){
				cp++;
			}
			right=cp;
		}
		for(int j=i;j<right;j++){
			mi[j]=right;
			i++;
		}
	}
	right=0;
	for(int i=0;i<n-1;i++){
		if(a[i]<=a[i+1]){
			int cp=i;
			while(cp<n-1&&a[cp]<=a[cp+1]){
				cp++;
			}
			right=cp;
		}
		for(int j=i;j<right;j++){
			ma[j]=right;
			i++;
		}
	}
	int m; cin >> m;
	for(int i=0;i<m;i++){
		int x,y; cin >> x >> y;
		if(x==y){
			cout << 1 << " " << 1 << endl;
		}
		else{
			cout << (ma[x]>=y?1:0) << " " << (mi[x]>=y?1:0) << endl;
		}
	}
}
0