結果

問題 No.905 Sorted?
ユーザー hibari2357hibari2357
提出日時 2019-10-11 22:07:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 1,553 bytes
コンパイル時間 1,309 ms
コンパイル使用メモリ 107,680 KB
実行使用メモリ 5,532 KB
最終ジャッジ日時 2023-08-16 18:04:05
合計ジャッジ時間 4,599 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 6 ms
4,384 KB
testcase_08 AC 191 ms
4,376 KB
testcase_09 AC 118 ms
4,380 KB
testcase_10 AC 185 ms
5,148 KB
testcase_11 AC 178 ms
4,908 KB
testcase_12 AC 207 ms
4,892 KB
testcase_13 AC 216 ms
5,148 KB
testcase_14 AC 216 ms
5,232 KB
testcase_15 AC 201 ms
5,532 KB
testcase_16 AC 218 ms
5,380 KB
testcase_17 AC 217 ms
5,376 KB
testcase_18 AC 160 ms
5,096 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for(ll &a:A){
        cin >> a;
    }
    
    vector<int> inc(N);
    vector<int> dec(N);
    
    
    int s = 0;
    int e = 1;
    for(int i=0; i<N-1; i++){
        if(A[i+1] >= A[i]) e++;
        else {
            for(int j=s; j<e; j++){
                inc[j] = e-1;
            }
            e = i+2;
            s = i+1;
        }
    }
    for(int j=s; j<e; j++){
        inc[j] = e-1;
    }
    
    
    s = 0;
    e = 1;
    for(int i=0; i<N-1; i++){
        if(A[i+1] <= A[i]) e++;
        else {
            for(int j=s; j<e; j++){
                dec[j] = e-1;
            }
            e = i+2;
            s = i+1;
        }
    }
    for(int j=s; j<e; j++){
        dec[j] = e-1;
    }
    
    
    int Q; cin >> Q;
    vector<int> L(Q), R(Q);
    for(int i=0; i<Q; i++){
        cin >> L[i] >> R[i];
    }
    
    for(int i=0; i<Q; i++){
        if(inc[L[i]] >= R[i]) cout << 1 << " ";
        else cout << 0 << " ";
        if(dec[L[i]] >= R[i]) cout << 1 << endl;
        else cout << 0 << endl;
    }
    
    
    
    return 0;
}
0