fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. void scanc(int &x)
  5. {
  6. register int c = getchar();
  7. x = 0;
  8. for(; (c<48 || c>57); c = getchar());
  9. for(; (c>47 && c<58) || c==46; c = getchar())
  10. {
  11. if(c==46) continue;
  12. // printf("%d\n",c);
  13. x = (x<<1) + (x<<3) + c - 48;
  14. }
  15. }
  16. void scanint(int &x)
  17. {
  18. register int c = getchar();
  19. x = 0;
  20. for(;(c<48 || c>57);c = getchar());
  21. for(;c>47 && c<58 ;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
  22. }
  23. int maks, t,n,wynik;
  24. int tab[1000];
  25. int rek(int x, int licz,int najm)
  26. {
  27. // if(tab[x+1] > tab[x]) rek(x+1,licz+1, najm);
  28. if(x == n) return 0;
  29. if(tab[x] < najm) { if(licz+1 > maks) maks = licz+1; rek(x+1,licz+1,tab[x]); }
  30. rek(x+1,licz,najm);
  31. // printf("tab = %d najm = %d\n",tab[x],najm);
  32. rek(x+1,1,tab[x]);
  33. return 0;
  34. }
  35. using namespace std;
  36. clock_t start, stop;
  37. double czas;
  38. int main()
  39. {
  40. scanint(t);
  41.  
  42. while(t--)
  43. {
  44. scanint(n);
  45.  
  46. for(int i=0; i<n; i++)
  47. {
  48. scanc(tab[i]);
  49. // printf("%d\n",wynik);
  50. }
  51. start = clock();
  52. rek(1,1,tab[0]);
  53. printf("%d\n",maks*100);
  54. stop = clock();
  55. czas = double(stop - start) / CLOCKS_PER_SEC;
  56. printf("czas = %.3lf\n",czas);
  57. }
  58. }
Time limit exceeded #stdin #stdout 5s 3100KB
stdin
1
24
22.806 22.807 22.002 22.004 22.003 22.405 22.802 22.003 22.405 22.802 22.304 22.043 22.006 22.207 22.205 22.202 22.304 22.043 22.002 22.007 22.005 22.002 22.004 22.003 
stdout
Standard output is empty