Guest User

Untitled

a guest
May 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, i, ans=0;
  8. cin >> n;
  9. vector< pair<int,int> > a(n);
  10. for (i = 0; i < n; i++) {
  11. cin >> a[i].first;
  12. a[i].second = i;
  13. }
  14. sort(a.begin(), a.end());
  15.  
  16. for (i = 0; i < n; i++) {
  17. if (ans < a[i].second-i) {
  18. ans = a[i].second - i;
  19. }
  20. }
  21. cout << ans + 1 << '\n';
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment