結果

問題 No.905 Sorted?
ユーザー tekihei2317tekihei2317
提出日時 2019-10-11 21:51:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 168,920 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-05-04 01:25:59
合計ジャッジ時間 3,792 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 123 ms
5,376 KB
testcase_09 AC 79 ms
5,376 KB
testcase_10 AC 108 ms
5,376 KB
testcase_11 AC 117 ms
5,376 KB
testcase_12 AC 138 ms
5,376 KB
testcase_13 AC 141 ms
5,760 KB
testcase_14 AC 129 ms
5,632 KB
testcase_15 AC 145 ms
5,632 KB
testcase_16 AC 142 ms
5,760 KB
testcase_17 AC 154 ms
5,760 KB
testcase_18 AC 109 ms
5,632 KB
testcase_19 AC 2 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>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    vector<int> R1(N),R2(N);
    for(int i=0;i<N;){
        int i0=i++;
        while(i<N and a[i-1]<=a[i]) i++;
        for(int j=i0;j<i;j++){
            R1[j]=i;
        }
    }
    for(int i=0;i<N;i++) a[i]*=-1;
    for(int i=0;i<N;){
        int i0=i++;
        while(i<N and a[i-1]<=a[i]) i++;
        for(int j=i0;j<i;j++){
            R2[j]=i;
        }
    }
    // for(int i=0;i<N;i++) cout<<R1[i]<<' '; cout<<endl;
    // for(int i=0;i<N;i++) cout<<R2[i]<<' '; cout<<endl;

    int Q; cin>>Q;
    while(Q--){
        int l,r; cin>>l>>r;
        cout<<(r<R1[l])<<' '<<(r<R2[l])<<endl;
    }
    return 0;
}
0