結果

問題 No.905 Sorted?
ユーザー k
提出日時 2020-08-09 18:54:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 2,605 ms
コンパイル使用メモリ 192,132 KB
最終ジャッジ日時 2025-01-12 19:23:29
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int n;
long long a[100000];
int f[100000], g[100000];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  REP (i, n) cin >> a[i];

  for (int i = 1; i < n; i++) {
    f[i] = f[i-1];
    g[i] = g[i-1];
    if (a[i-1] <= a[i]) ++f[i];
    if (a[i-1] >= a[i]) ++g[i];
  }
  
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (f[r] - f[l] == r - l ? 1 : 0) << " ";
    cout << (g[r] - g[l] == r - l ? 1 : 0) << endl;
  }
  
  return 0;
}
0