結果

問題 No.905 Sorted?
ユーザー kyort0nkyort0n
提出日時 2019-10-11 21:35:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 166,484 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 01:07:51
合計ジャッジ時間 4,136 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 127 ms
6,944 KB
testcase_09 AC 103 ms
5,376 KB
testcase_10 AC 109 ms
5,376 KB
testcase_11 AC 122 ms
5,376 KB
testcase_12 AC 150 ms
5,376 KB
testcase_13 AC 124 ms
5,376 KB
testcase_14 AC 133 ms
5,376 KB
testcase_15 AC 143 ms
5,376 KB
testcase_16 AC 148 ms
5,376 KB
testcase_17 AC 147 ms
5,376 KB
testcase_18 AC 109 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,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