結果

問題 No.905 Sorted?
ユーザー kyort0nkyort0n
提出日時 2019-10-11 21:35:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 165,204 KB
実行使用メモリ 5,072 KB
最終ジャッジ日時 2023-08-16 17:18:58
合計ジャッジ時間 4,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 121 ms
4,380 KB
testcase_09 AC 77 ms
4,380 KB
testcase_10 AC 107 ms
4,808 KB
testcase_11 AC 115 ms
4,576 KB
testcase_12 AC 136 ms
4,476 KB
testcase_13 AC 122 ms
5,004 KB
testcase_14 AC 123 ms
4,956 KB
testcase_15 AC 148 ms
4,944 KB
testcase_16 AC 142 ms
4,956 KB
testcase_17 AC 145 ms
5,072 KB
testcase_18 AC 105 ms
4,976 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
ll A[100500];
int B[100500];
int C[100500];
int Bsum[100500];
int Csum[100500];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 1; i < N; i++) {
        Bsum[i] = Bsum[i-1];
        Csum[i] = Csum[i-1];
        if(A[i] >= A[i-1]) Bsum[i]++;
        if(A[i] <= A[i-1]) Csum[i]++;
    }
    int Q;
    cin >> Q;
    while(Q--) {
        int l, r;
        cin >> l >> r;
        if(Bsum[r] - Bsum[l] == r - l) cout << 1;
        else cout << 0;
        cout << " ";
        if(Csum[r] - Csum[l] == r - l) cout << 1;
        else cout << 0;
        cout << endl;
    }
    return 0;
}
0