結果

問題 No.905 Sorted?
ユーザー ats5515ats5515
提出日時 2019-10-11 22:42:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 82,836 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-05-04 02:28:12
合計ジャッジ時間 3,792 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 148 ms
5,376 KB
testcase_09 AC 93 ms
5,376 KB
testcase_10 AC 133 ms
5,376 KB
testcase_11 AC 143 ms
5,376 KB
testcase_12 AC 166 ms
5,376 KB
testcase_13 AC 155 ms
5,632 KB
testcase_14 AC 153 ms
5,504 KB
testcase_15 AC 168 ms
5,504 KB
testcase_16 AC 167 ms
5,632 KB
testcase_17 AC 171 ms
5,504 KB
testcase_18 AC 119 ms
5,632 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> X(N);
	vector<int> Y(N);

	for (int i = 0; i < N - 1; i++) {
		if (A[i] > A[i + 1]) {
			X[i + 1] = 1;
		}
		else if (A[i] < A[i + 1]) {
			Y[i + 1] = 1;
		}
	}
	for (int i = 1; i < N; i++) {
		X[i] += X[i - 1];
		Y[i] += Y[i - 1];
	}
	int Q;
	cin >> Q;
	int l, r;
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << ((X[r] - X[l]) > 0 ? 0 : 1) << " " << ((Y[r] - Y[l]) > 0 ? 0 : 1) << endl;
	}
}
0