fork download
  1. #include <cstdio>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <functional>
  5. using namespace std;
  6. typedef vector<int> vi;
  7. #define FOR(t, b, e, it) for(t::iterator it=b;it!=e;it++)
  8.  
  9.  
  10. int main(){
  11. int tmp, ctr=0;
  12. vi m;
  13.  
  14. scanf("%d", &tmp);
  15. while(tmp!=-1){
  16. vi::iterator i;
  17. m.clear();
  18. while(tmp!=-1){
  19. i=upper_bound(m.begin(), m.end(), tmp, greater<int>());
  20. if(i==m.end()) m.push_back(tmp);
  21. else *i=tmp;
  22. scanf("%d", &tmp);
  23. }
  24. if(ctr)printf("\n");
  25. printf("Test #%d:\n maximum possible interceptions: %d\n",++ctr, m.size());
  26. scanf("%d", &tmp);
  27.  
  28. }
  29. return 0;
  30. }
  31.  
  32.  
Success #stdin #stdout 0s 2820KB
stdin
389
207
155
300
299
170
158
65
-1
23
34
21
-1
-1
stdout
Test #1:
  maximum possible interceptions: 6

Test #2:
  maximum possible interceptions: 2