結果
| 問題 |
No.905 Sorted?
|
| コンテスト | |
| ユーザー |
tekihei2317
|
| 提出日時 | 2019-10-11 21:51:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 144 ms / 2,000 ms |
| コード長 | 1,004 bytes |
| コンパイル時間 | 1,534 ms |
| コンパイル使用メモリ | 169,964 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-25 07:14:31 |
| 合計ジャッジ時間 | 4,117 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int N; cin>>N;
vector<int> a(N);
for(int i=0;i<N;i++) cin>>a[i];
vector<int> R1(N),R2(N);
for(int i=0;i<N;){
int i0=i++;
while(i<N and a[i-1]<=a[i]) i++;
for(int j=i0;j<i;j++){
R1[j]=i;
}
}
for(int i=0;i<N;i++) a[i]*=-1;
for(int i=0;i<N;){
int i0=i++;
while(i<N and a[i-1]<=a[i]) i++;
for(int j=i0;j<i;j++){
R2[j]=i;
}
}
// for(int i=0;i<N;i++) cout<<R1[i]<<' '; cout<<endl;
// for(int i=0;i<N;i++) cout<<R2[i]<<' '; cout<<endl;
int Q; cin>>Q;
while(Q--){
int l,r; cin>>l>>r;
cout<<(r<R1[l])<<' '<<(r<R2[l])<<endl;
}
return 0;
}
tekihei2317