結果
| 問題 | No.905 Sorted? | 
| コンテスト | |
| ユーザー |  milanis48663220 | 
| 提出日時 | 2019-10-11 21:49:26 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 157 ms / 2,000 ms | 
| コード長 | 1,069 bytes | 
| コンパイル時間 | 494 ms | 
| コンパイル使用メモリ | 65,956 KB | 
| 実行使用メモリ | 7,264 KB | 
| 最終ジャッジ日時 | 2024-11-25 07:13:48 | 
| 合計ジャッジ時間 | 3,334 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
long A[100000];
long pos[100001];
long neg[100001];
long pos_sum[100001];
long neg_sum[100001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(i >= 1){
            if(A[i] > A[i-1]) pos[i-1] = 1;
            if(A[i] < A[i-1]) neg[i-1] = 1;
            pos_sum[i] = pos_sum[i-1]+pos[i-1];
            neg_sum[i] = neg_sum[i-1]+neg[i-1];
        }
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        if(l == r){
            cout << 1 << ' ' << 1 << endl;
        }else{
            if(neg_sum[r] > neg_sum[l]){
                cout << 0;
            }else{
                cout << 1;
            }
            cout << ' ';
            if(pos_sum[r] > pos_sum[l]){
                cout << 0;
            }else{
                cout << 1;
            }
            cout << endl;
        }
    }
}
            
            
            
        