結果

問題 No.905 Sorted?
ユーザー i_mrhji_mrhj
提出日時 2019-10-11 22:38:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 76,212 KB
実行使用メモリ 5,556 KB
最終ジャッジ日時 2023-08-16 18:52:37
合計ジャッジ時間 4,426 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 192 ms
4,380 KB
testcase_09 AC 112 ms
4,380 KB
testcase_10 AC 177 ms
5,448 KB
testcase_11 AC 172 ms
4,980 KB
testcase_12 AC 200 ms
4,644 KB
testcase_13 AC 214 ms
5,528 KB
testcase_14 AC 206 ms
5,364 KB
testcase_15 AC 204 ms
5,492 KB
testcase_16 AC 211 ms
5,444 KB
testcase_17 AC 212 ms
5,444 KB
testcase_18 AC 159 ms
5,556 KB
testcase_19 AC 1 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,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long MOD = 1000000007;

typedef long long ll;

int
main(int argc, char *argv[])
{
  int n; cin >> n;
  vector<ll> a(n + 1);
  rep(i, n) cin >> a[i];
  vector<ll> d(n + 1);
  rep(i, n - 1) d[i] = a[i + 1] - a[i];
  vector<int> c1(n + 1, 0), c2(n + 1, 0);
  rep(i, n) {
    if (d[i] < 0) c1[i + 1] = c1[i] + 1;
    else c1[i + 1] = c1[i];
    if (d[i] > 0) c2[i + 1] = c2[i] + 1;
    else c2[i + 1] = c2[i];
  }
  int q, l, r;
  cin >> q;
  rep(i, q) {
    cin >> l >> r;
    if (c1[r] - c1[l] > 0) cout << 0 << " ";
    else cout << 1 << " ";
    if (c2[r] - c2[l] > 0) cout << 0 << endl;
    else cout << 1 << endl;
  }
  return 0;
}
0