Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(){
- int n, m;
- cin >> n >> m;
- vector <bool> curva_p_cima = vector <bool>(n, false);
- int v0, v1;
- cin >> v0;
- int inclinacao = 0;
- for(int i = 1; i < n; i++){
- cin >> v1;
- if(v1 > v0){
- if(inclinacao < 0){
- curva_p_cima[i] = 1;
- }
- inclinacao = 1;
- } else if (v1 < v0){
- inclinacao = -1;
- } else {
- inclinacao = 0;
- }
- v0 = v1;
- }
- vector<int> soma = vector <int> (n, 0);
- for(int i = 1; i < n; i++){
- soma[i] = soma[i-1]+curva_p_cima[i];
- }
- for(int i = 0 ; i < m; i++){
- int l, f;
- cin >> l >> f;
- l--; f--;
- int soma_dir = soma[f];
- int soma_esq = soma[l];
- if(l+1 < n && f-l+1 > 1 && curva_p_cima[l+1]) soma_esq++;
- if(soma_dir - soma_esq == 0) puts("Yes");
- else puts("No");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement