結果

問題 No.905 Sorted?
ユーザー hibari2357hibari2357
提出日時 2019-10-11 22:06:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,555 bytes
コンパイル時間 1,010 ms
コンパイル使用メモリ 107,064 KB
実行使用メモリ 5,020 KB
最終ジャッジ日時 2023-08-16 18:00:45
合計ジャッジ時間 3,442 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 5 ms
4,384 KB
testcase_08 WA -
testcase_09 AC 101 ms
4,384 KB
testcase_10 WA -
testcase_11 AC 151 ms
4,752 KB
testcase_12 AC 175 ms
4,608 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 177 ms
5,020 KB
testcase_16 AC 187 ms
5,020 KB
testcase_17 AC 188 ms
4,944 KB
testcase_18 AC 138 ms
4,620 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,384 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<int> A(N);
    for(int &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