結果

問題 No.905 Sorted?
ユーザー face4face4
提出日時 2019-09-24 14:33:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 66,788 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-14 08:47:17
合計ジャッジ時間 7,689 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// TLEになってほしい
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

ll a[100000];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)  scanf("%lld", a+i);
    int q;
    scanf("%d", &q);
    while(q-- > 0){
        int l, r;
        scanf("%d %d", &l, &r);
        bool asc = true, dec = true;
        l++;
        while(l <= r && (asc || dec)){
            if(a[l-1] > a[l])   asc = false;
            if(a[l-1] < a[l])   dec = false;
            l++;
        }
        if(asc && dec)  printf("0\n");
        else if(asc)    printf("1\n");
        else if(dec)    printf("-1\n");
        else            printf("2\n");
    }
    return 0;
}
0