結果

問題 No.905 Sorted?
ユーザー Mayimg
提出日時 2019-10-13 05:57:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 196,580 KB
最終ジャッジ日時 2025-01-07 21:59:27
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> inc(n), dec(n);
  for (int i = 1; i < n; i++) {
    inc[i] = inc[i - 1] + (a[i] < a[i - 1]);
    dec[i] = dec[i - 1] + (a[i] > a[i - 1]);
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (inc[l] == inc[r]) << " " << (dec[l] == dec[r]) << '\n';
  }
  return 0;
}
0