結果

問題 No.905 Sorted?
ユーザー Y17Y17
提出日時 2019-10-11 21:59:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 144,656 KB
実行使用メモリ 5,940 KB
最終ジャッジ日時 2023-08-16 17:48:51
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,948 KB
testcase_01 AC 2 ms
4,944 KB
testcase_02 AC 2 ms
5,012 KB
testcase_03 AC 2 ms
5,164 KB
testcase_04 AC 2 ms
5,140 KB
testcase_05 AC 4 ms
4,920 KB
testcase_06 AC 3 ms
4,968 KB
testcase_07 AC 6 ms
5,020 KB
testcase_08 AC 175 ms
5,320 KB
testcase_09 AC 102 ms
5,240 KB
testcase_10 AC 159 ms
5,624 KB
testcase_11 AC 157 ms
5,512 KB
testcase_12 AC 181 ms
5,492 KB
testcase_13 AC 189 ms
5,680 KB
testcase_14 AC 188 ms
5,940 KB
testcase_15 AC 181 ms
5,664 KB
testcase_16 AC 192 ms
5,696 KB
testcase_17 AC 191 ms
5,736 KB
testcase_18 AC 143 ms
5,668 KB
testcase_19 AC 3 ms
4,904 KB
testcase_20 AC 2 ms
5,120 KB
testcase_21 AC 2 ms
4,956 KB
testcase_22 AC 2 ms
4,956 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