結果

問題 No.905 Sorted?
ユーザー risujirohrisujiroh
提出日時 2019-10-11 21:38:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 167,564 KB
実行使用メモリ 4,668 KB
最終ジャッジ日時 2023-08-16 17:23:11
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 29 ms
4,376 KB
testcase_09 AC 18 ms
4,376 KB
testcase_10 AC 33 ms
4,560 KB
testcase_11 AC 27 ms
4,380 KB
testcase_12 AC 30 ms
4,380 KB
testcase_13 AC 37 ms
4,644 KB
testcase_14 AC 37 ms
4,564 KB
testcase_15 AC 31 ms
4,608 KB
testcase_16 AC 34 ms
4,668 KB
testcase_17 AC 33 ms
4,608 KB
testcase_18 AC 27 ms
4,640 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n); for (auto&& e : a) cin >> e;
  V<> b(n), c(n);
  for (int i = 0; i < n - 1; ++i) {
    b[i] = a[i] <= a[i + 1];
    c[i] = a[i] >= a[i + 1];
  }
  for (int i = n - 2; i >= 0; --i) {
    b[i] += b[i + 1];
    c[i] += c[i + 1];
  }
  int q; cin >> q;
  while (q--) {
    int l, r; cin >> l >> r;
    cout << (b[l] - b[r] == r - l) << ' ' << (c[l] - c[r] == r - l) << '\n';
  }
}
0