Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<iostream>
- int main()
- {
- int T,i;
- long long N,k,j,C,Q,A,B,D,K,r=0;
- long long big,small,store,store1,store2;
- scanf("%d",&T);
- for(i=1;i<=T;i++)
- {
- scanf("%d%d%d%d%d%d",N,C,Q,A,B,D);
- long long M[Q];
- long long skill[N];
- long long cand[N];
- if(N<=10000)
- {
- for(k=0;k<N;k++)
- {
- scanf("%d",&skill[N]);
- cand[k]=0;
- }
- }
- else
- {
- for(k=0;k<10000;k++)
- {
- scanf("%d",&skill[N]);
- cand[k]=0;
- }
- for(k=10000;k<N;k++)
- {
- skill[k]=(A*skill[k-1]+B*skill[k-2]+D)%(int)(pow(2,30));
- cand[k]=0;
- }
- }
- for(k=0;k<Q;k++)
- scanf("%d",&M[k]);
- big=skill[0];
- small=skill[0];
- for(r=0;r<Q;r++)
- {
- store=1;
- for(k=0;k<N;k++)
- {
- for(j=k+1;j<N;j++)
- {
- if(big<skill[k])
- big=skill[k];
- if(small>skill[k])
- small=skill[k];
- if((small-big)<=C)
- store++;
- else
- {
- if(cand[store-1]==M[r])
- {
- cand[store-1]=0;
- break;
- }
- else
- {
- cand[store-1]++;
- break;
- }
- }
- }
- }
- store1=1,store2=1;
- for(k=0;k<N&&cand[k]>1;k++)
- {
- if(cand[k]==M[r])
- {
- store=cand[k];
- break;
- }
- if(store<cand[k])
- {
- store1=cand[k];
- store2=k+1;
- }
- }
- printf("%d %d",store2,store1);
- }
- }
- system("pause");
- }
Add Comment
Please, Sign In to add comment