Advertisement
bappi2097

J - Jeronimo's List

Aug 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     ios_base::sync_with_stdio(false);
  6.     cin.tie(NULL);
  7.     #ifndef ONLINE_JUDGE
  8.     freopen("input.txt","r",stdin);
  9.     #endif // ONLINE_JUDGE
  10.     int n,m,q,mod=30000000;
  11.     cin>>n>>m>>q;
  12.     int arm[n],b[q];
  13.     for(int i=0;i<m;i++)cin>>arm[i];
  14.  
  15.     for(int i=m;i<n;i++)
  16.     {
  17.         arm[i]=(arm[i-m]+arm[i-m+1])%mod;
  18.     }
  19.     sort(arm,arm+n);
  20.    
  21.     for(int i=0;i<q;i++)
  22.     {
  23.         cin>>b[i];
  24.         cout<<arm[b[i]-1]<<endl;
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement