結果

問題 No.905 Sorted?
ユーザー Y17Y17
提出日時 2019-10-11 21:59:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 158,960 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-05-04 01:35:51
合計ジャッジ時間 4,716 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,632 KB
testcase_01 AC 3 ms
5,888 KB
testcase_02 AC 3 ms
5,760 KB
testcase_03 AC 3 ms
5,760 KB
testcase_04 AC 3 ms
5,888 KB
testcase_05 AC 4 ms
5,632 KB
testcase_06 AC 4 ms
5,632 KB
testcase_07 AC 7 ms
5,760 KB
testcase_08 AC 186 ms
5,632 KB
testcase_09 AC 123 ms
5,760 KB
testcase_10 AC 179 ms
5,760 KB
testcase_11 AC 172 ms
5,760 KB
testcase_12 AC 199 ms
5,760 KB
testcase_13 AC 211 ms
5,760 KB
testcase_14 AC 211 ms
5,888 KB
testcase_15 AC 193 ms
5,760 KB
testcase_16 AC 205 ms
5,632 KB
testcase_17 AC 211 ms
5,760 KB
testcase_18 AC 154 ms
5,760 KB
testcase_19 AC 3 ms
5,760 KB
testcase_20 AC 3 ms
5,760 KB
testcase_21 AC 3 ms
5,760 KB
testcase_22 AC 3 ms
5,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    int n;
    cin >> n;

    int a[100010];

    int f[100010] = {};
    int g[100010] = {};

    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    for(int i = 0;i < n-1;i++){
        if(a[i] <= a[i+1]) f[i+1] = 1;
        if(a[i] >= a[i+1]) g[i+1] = 1;
        f[i+1] += f[i];
        g[i+1] += g[i];
    }

    int q;
    cin >> q;
    while(q--){
        int l, r;
        cin >> l >> r;

        int lans = (f[r] - f[l]) == r-l ? 1 : 0;
        int rans = (g[r] - g[l]) == r-l ? 1 : 0;
        cout << lans << " "<< rans << endl;
    }

    return 0;
}
0