結果
| 問題 | No.905 Sorted? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-10-12 23:07:46 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,172 bytes | 
| コンパイル時間 | 1,594 ms | 
| コンパイル使用メモリ | 171,548 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-29 16:57:23 | 
| 合計ジャッジ時間 | 5,897 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 13 WA * 10 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  vector<pair<int, int> > inc;
  int i = 0;
  while (i < n) {
    int s = i;
    while (i < n - 1 && a[i] <= a[i+1]) {
      ++i;
    }
    if (i > s) {
      inc.emplace_back(s, i - s + 1);
    } else {
      ++i;
    }
  }
  vector<pair<int, int> > dec;
  i = 0;
  while (i < n) {
    int s = i;
    while (i < n - 1 && a[i] >= a[i+1]) {
      ++i;
    }
    if (i > s) {
      dec.emplace_back(s, i - s + 1);
    } else {
      ++i;
    }
  }
  int q;
  cin>>q;
  for (i=0; i<q; i++) {
    int l, r;
    cin>>l>>r;
    auto it = upper_bound(inc.begin(), inc.end(), make_pair(l, INT_MAX));
    int f = 0;
    if (it != inc.begin()) {
      --it;
      int s = (*it).first;
      int len =(*it).second;
      if (r <= s + len - 1) {
        f = 1;
      }
    }
    it = upper_bound(dec.begin(), dec.end(), make_pair(l, INT_MAX));
    int g = 0;
    if (it != dec.begin()) {
      --it;
      int s = (*it).first;
      int len =(*it).second;
      if (r <= s + len - 1) {
        g = 1;
      }
    }
    cout<<f<<" "<<g<<endl;
  }
}
            
            
            
        