Advertisement
Guest User

Rares - Problema Informatica

a guest
Jan 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int v[10001],poz[10001];
  7.  
  8. int n,x = 1,k;
  9. int maxBooks, firstDay, Day = 1;
  10. int main() {
  11.     cin >> n;
  12.     for(int i = 1; i <= n; i++) {
  13.         cin >> v[i];
  14.         poz[v[i]] = i;
  15.     }
  16.     for(int i = 1; i < n; i ++) {
  17.         for(int j = i+1; j <= n; j++) {
  18.             if(v[i] > v[j])
  19.                 swap(v[i],v[j]);
  20.         }
  21.     }
  22.     for(int i = 1; i <= n; i++) {
  23.         if(poz[v[i]] > poz[v[i-1]]) {
  24.             k++;
  25.         }
  26.         else {
  27.             if(k > maxBooks) maxBooks = k,firstDay=Day;
  28.             Day++;
  29.             k = 1;
  30.         }
  31.     }
  32.     cout << Day << ' ' << firstDay << ' ' << maxBooks;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement