結果

問題 No.905 Sorted?
ユーザー 👑 emthrmemthrm
提出日時 2019-10-11 21:42:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,414 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 119,900 KB
実行使用メモリ 4,676 KB
最終ジャッジ日時 2023-08-16 17:28:42
合計ジャッジ時間 2,999 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  vector<int> inc(n, 0), dec(n, 0);
  REP(i, n - 1) {
    if (a[i] <= a[i + 1]) inc[i + 1] = 1;
    inc[i + 1] += inc[i];
    if (a[i] >= a[i + 1]) dec[i + 1] = 1;
    dec[i + 1] += dec[i];
  }
  int q; cin >> q;
  while (q--) {
    int l, r; cin >> l >> r;
    cout << (inc[r] - inc[l] == r - l ? 1 : 0) << ' ' << (dec[r] - dec[l] == r - l ? 1 : 0) << '\n';
  }
}
0