結果

問題 No.905 Sorted?
ユーザー iqueue02iqueue02
提出日時 2019-10-22 21:29:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 169,120 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-18 03:50:28
合計ジャッジ時間 6,322 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 199 ms
4,380 KB
testcase_09 AC 122 ms
4,384 KB
testcase_10 AC 187 ms
4,664 KB
testcase_11 AC 185 ms
4,456 KB
testcase_12 AC 213 ms
4,376 KB
testcase_13 AC 222 ms
4,564 KB
testcase_14 AC 222 ms
4,564 KB
testcase_15 AC 211 ms
4,648 KB
testcase_16 AC 227 ms
4,604 KB
testcase_17 AC 223 ms
4,604 KB
testcase_18 AC 165 ms
4,752 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin  >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<int> up(n,0), low(n,0);
  for (int i = 1; i < n; i++) {
    if (a[i-1] <= a[i]) up[i] = 1;
    if (a[i-1] >= a[i]) low[i] = 1;
  }
  rep(i,n-1) up[i+1] += up[i], low[i+1] += low[i];
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    vector<int> res(2,0);
    if (up[r] -  up[l] == r - l) res[0]++;
    if (low[r] - low[l] == r - l) res[1]++;
    cout << res[0] << " " << res[1] << endl; 
  }
  return 0;
}
0