結果

問題 No.905 Sorted?
ユーザー ats5515ats5515
提出日時 2019-10-11 22:42:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 77,964 KB
実行使用メモリ 5,512 KB
最終ジャッジ日時 2023-08-16 18:57:01
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 122 ms
4,380 KB
testcase_09 AC 77 ms
4,376 KB
testcase_10 AC 111 ms
5,144 KB
testcase_11 AC 118 ms
4,880 KB
testcase_12 AC 137 ms
4,548 KB
testcase_13 AC 123 ms
5,480 KB
testcase_14 AC 125 ms
5,328 KB
testcase_15 AC 142 ms
5,344 KB
testcase_16 AC 144 ms
5,512 KB
testcase_17 AC 145 ms
5,388 KB
testcase_18 AC 104 ms
5,480 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,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