Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include<iostream>
  2. #include<list>
  3. #include<cstdio>
  4. #include<vector>
  5. #include<string>
  6. #include<algorithm>
  7. #include<queue>
  8. #include<cmath>
  9. #include<map>
  10. #pragma comment(linker, "/STACK:367772160")
  11. using namespace std;
  12. int a[11000];
  13. int tmp[11000];
  14. int main()
  15. {
  16.     std::ios::sync_with_stdio(0);
  17.     int n;
  18.     int cnt = 0;
  19.     int l = 1, r = 1;
  20.     bool ok = true;
  21.     cin >> n;
  22.     for (int i = 1; i <= n; i++)
  23.     {
  24.         cin >> a[i];
  25.     }
  26.     a[0] = -1000000;
  27.     a[n + 1] = 1000000;
  28.     for (int i = 1; i <= n; i++)
  29.     {
  30.         if (a[i] > a[i + 1])
  31.         {
  32.             if (ok)
  33.             {
  34.                 l = i;
  35.  
  36.                 ok = false;
  37.  
  38.                 cnt++;
  39.             }
  40.         }
  41.         else
  42.         {
  43.             if (!ok) r = i;
  44.  
  45.             ok = true;
  46.         }
  47.     }
  48.     if (cnt>1 || (cnt == 1 && (a[l - 1]>a[r] || a[l]>a[r + 1]))) cout << "no\n";
  49.     else cout << "yes\n" << l << " " << r << endl;
  50.     system("pause");
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement