結果

問題 No.905 Sorted?
ユーザー NoiriNoiri
提出日時 2019-10-12 09:12:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 2,623 ms
コンパイル使用メモリ 167,616 KB
実行使用メモリ 5,536 KB
最終ジャッジ日時 2023-08-18 06:30:55
合計ジャッジ時間 6,568 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 197 ms
4,380 KB
testcase_09 AC 122 ms
4,376 KB
testcase_10 AC 188 ms
5,096 KB
testcase_11 AC 181 ms
4,832 KB
testcase_12 AC 208 ms
4,568 KB
testcase_13 AC 224 ms
5,416 KB
testcase_14 AC 221 ms
5,408 KB
testcase_15 AC 207 ms
5,536 KB
testcase_16 AC 222 ms
5,408 KB
testcase_17 AC 222 ms
5,524 KB
testcase_18 AC 163 ms
5,492 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n), is(n+1), ds(n+1);
    rep(i, n) cin >> v[i];

    for(int i=1; i<n; i++){
        is[i] = (v[i-1] <= v[i]);
        is[i] += is[i-1];
        ds[i] = (v[i-1] >= v[i]);
        ds[i] += ds[i-1];
    }

    int q;
    cin >> q;
    rep(_, q){
        int l, r;
        cin >> l >> r;
        cout << (is[r]-is[l] == r-l) << " " << (ds[r]-ds[l] == r-l) << endl;
    }
}
0