結果

問題 No.905 Sorted?
ユーザー a01sa01to
提出日時 2025-04-29 00:35:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 3,629 ms
コンパイル使用メモリ 279,560 KB
実行使用メモリ 8,952 KB
最終ジャッジ日時 2025-04-29 00:36:02
合計ジャッジ時間 5,575 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

#include <atcoder/segtree>
ll op1(ll a, ll b) { return max(a, b); }
ll e1() { return -3e18; }
ll op2(ll a, ll b) { return min(a, b); }
ll e2() { return 3e18; }

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  atcoder::segtree<ll, op1, e1> maxseg(n - 1);
  atcoder::segtree<ll, op2, e2> minseg(n - 1);
  rep(i, n - 1) {
    maxseg.set(i, a[i + 1] - a[i]);
    minseg.set(i, a[i + 1] - a[i]);
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (minseg.prod(l, r) >= 0 ? 1 : 0) << ' ' << (maxseg.prod(l, r) <= 0 ? 1 : 0) << '\n';
  }
  return 0;
}
0