結果

問題 No.905 Sorted?
ユーザー tekihei2317tekihei2317
提出日時 2019-10-11 21:51:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 167,720 KB
実行使用メモリ 5,464 KB
最終ジャッジ日時 2023-08-16 17:38:03
合計ジャッジ時間 4,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 142 ms
4,376 KB
testcase_09 AC 91 ms
4,380 KB
testcase_10 AC 129 ms
5,216 KB
testcase_11 AC 137 ms
4,848 KB
testcase_12 AC 163 ms
4,544 KB
testcase_13 AC 146 ms
5,412 KB
testcase_14 AC 147 ms
5,412 KB
testcase_15 AC 164 ms
5,360 KB
testcase_16 AC 167 ms
5,464 KB
testcase_17 AC 164 ms
5,364 KB
testcase_18 AC 119 ms
5,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 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