Guest User

Untitled

a guest
Jan 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<iostream>
  4. int main()
  5. {
  6. int T,i;
  7. long long N,k,j,C,Q,A,B,D,K,r=0;
  8. long long big,small,store,store1,store2;
  9. scanf("%d",&T);
  10. for(i=1;i<=T;i++)
  11. {
  12. scanf("%d%d%d%d%d%d",N,C,Q,A,B,D);
  13. long long M[Q];
  14. long long skill[N];
  15. long long cand[N];
  16. if(N<=10000)
  17. {
  18. for(k=0;k<N;k++)
  19. {
  20. scanf("%d",&skill[N]);
  21. cand[k]=0;
  22. }
  23. }
  24. else
  25. {
  26. for(k=0;k<10000;k++)
  27. {
  28. scanf("%d",&skill[N]);
  29. cand[k]=0;
  30. }
  31. for(k=10000;k<N;k++)
  32. {
  33. skill[k]=(A*skill[k-1]+B*skill[k-2]+D)%(int)(pow(2,30));
  34. cand[k]=0;
  35. }
  36. }
  37. for(k=0;k<Q;k++)
  38. scanf("%d",&M[k]);
  39. big=skill[0];
  40. small=skill[0];
  41. for(r=0;r<Q;r++)
  42. {
  43. store=1;
  44. for(k=0;k<N;k++)
  45. {
  46. for(j=k+1;j<N;j++)
  47. {
  48. if(big<skill[k])
  49. big=skill[k];
  50. if(small>skill[k])
  51. small=skill[k];
  52. if((small-big)<=C)
  53. store++;
  54. else
  55. {
  56. if(cand[store-1]==M[r])
  57. {
  58. cand[store-1]=0;
  59. break;
  60. }
  61. else
  62. {
  63. cand[store-1]++;
  64. break;
  65. }
  66. }
  67. }
  68. }
  69. store1=1,store2=1;
  70. for(k=0;k<N&&cand[k]>1;k++)
  71. {
  72. if(cand[k]==M[r])
  73. {
  74. store=cand[k];
  75. break;
  76. }
  77. if(store<cand[k])
  78. {
  79. store1=cand[k];
  80. store2=k+1;
  81. }
  82. }
  83. printf("%d %d",store2,store1);
  84. }
  85. }
  86. system("pause");
  87. }
Add Comment
Please, Sign In to add comment