Advertisement
Saleh127

UVA 231

Dec 10th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll lis( ll arr[], ll n )
  6. {
  7. ll lis[n],i,j;
  8. lis[0] = 1;
  9. for (i = 1; i < n; i++ )
  10. {
  11. lis[i] = 1;
  12. for (j = 0; j < i; j++ )
  13. {
  14. if ( arr[j] >= arr[i] && lis[i] < lis[j] + 1)
  15. {
  16. lis[i] = lis[j] + 1;
  17. }
  18. }
  19. }
  20. return *max_element(lis,lis+n);
  21. }
  22. int main()
  23. {
  24. ios_base::sync_with_stdio(0);
  25. cin.tie(0);
  26. cout.tie(0);
  27.  
  28. ll a[10000],n,i,j,k,l=0;
  29. while(cin>>a[0] && a[0]!=-1)
  30. {
  31. n=1;
  32. while(cin>>a[n] && a[n]!=-1)
  33. {
  34. n++;
  35. }
  36. if(l) cout<<endl;
  37.  
  38. cout<<"Test #"<<++l<<":"<<endl;
  39. cout<<" maximum possible interceptions: "<<lis(a,n)<<endl;
  40. }
  41.  
  42.  
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement