結果

問題 No.905 Sorted?
ユーザー pekempeypekempey
提出日時 2019-10-11 21:24:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 168,720 KB
実行使用メモリ 4,828 KB
最終ジャッジ日時 2023-08-16 16:53:42
合計ジャッジ時間 6,314 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 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 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 143 ms
4,380 KB
testcase_09 AC 89 ms
4,384 KB
testcase_10 AC 125 ms
4,660 KB
testcase_11 AC 136 ms
4,384 KB
testcase_12 AC 159 ms
4,380 KB
testcase_13 AC 144 ms
4,676 KB
testcase_14 AC 144 ms
4,628 KB
testcase_15 AC 161 ms
4,568 KB
testcase_16 AC 164 ms
4,560 KB
testcase_17 AC 163 ms
4,648 KB
testcase_18 AC 118 ms
4,828 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];
  vector<int> le(N);
  vector<int> ge(N);
  rep(i, N - 1) {
    le[i + 1] = le[i] + (a[i] <= a[i + 1]);
  }
  rep(i, N - 1) {
    ge[i + 1] = ge[i] + (a[i] >= a[i + 1]);
  }
  int q; cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    int ans0 = (le[r] - le[l]) == (r - l);
    int ans1 = (ge[r] - ge[l]) == (r - l);
    cout << ans0 << ' ' << ans1 << endl;
  }
}
0