結果

問題 No.905 Sorted?
ユーザー tko919
提出日時 2019-10-12 00:15:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 169,976 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 20:53:48
合計ジャッジ時間 3,367 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<ll> a(n);
    rep(i,0,n)scanf("%lld",&a[i]);
    ll rui[2][100010]={};
    rep(i,0,n-1)rui[0][i+1]=(a[i]<=a[i+1]),rui[1][i+1]=(a[i]>=a[i+1]);
    rep(i,0,n-1)rui[0][i+1]+=rui[0][i],rui[1][i+1]+=rui[1][i];
    int q; scanf("%d",&q);
    rep(i,0,q){
        int l,r; scanf("%d%d",&l,&r);
        printf("%d %d\n",(rui[0][r]-rui[0][l]==r-l),(rui[1][r]-rui[1][l]==r-l));
    }
    return 0;
}
0