結果
問題 | No.905 Sorted? |
ユーザー | m-44 |
提出日時 | 2019-10-12 23:07:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,172 bytes |
コンパイル時間 | 1,542 ms |
コンパイル使用メモリ | 170,044 KB |
実行使用メモリ | 5,112 KB |
最終ジャッジ日時 | 2023-08-19 21:10:23 |
合計ジャッジ時間 | 7,076 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 3 ms
4,380 KB |
testcase_06 | AC | 3 ms
4,376 KB |
testcase_07 | AC | 6 ms
4,380 KB |
testcase_08 | WA | - |
testcase_09 | AC | 122 ms
4,380 KB |
testcase_10 | WA | - |
testcase_11 | AC | 188 ms
4,380 KB |
testcase_12 | AC | 224 ms
4,376 KB |
testcase_13 | AC | 220 ms
4,380 KB |
testcase_14 | AC | 220 ms
4,376 KB |
testcase_15 | AC | 214 ms
5,112 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 165 ms
4,380 KB |
testcase_19 | WA | - |
testcase_20 | AC | 1 ms
4,376 KB |
testcase_21 | AC | 2 ms
4,376 KB |
testcase_22 | AC | 1 ms
4,376 KB |
ソースコード
#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; } }