Guest User

Untitled

a guest
Dec 27th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. int arr[100005];
  5. int main() {
  6.  
  7. #ifndef ONLINE_JUDGE
  8. freopen("input.txt", "r", stdin);
  9. freopen("output.txt", "w", stdout);
  10. #endif
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(NULL);
  13. /*---------------------------------------------------------------------------------*/
  14. ll T, n, Q, a, large;
  15. cin >> T;
  16. while(T--)
  17. {
  18. cin >> n >> Q;
  19. for(ll i=0; i<n; i++) cin >>arr[i];
  20. while(Q--)
  21. {
  22. cin >> a;
  23. large = arr[0];
  24. for(ll j = 0; j<a; j++) {
  25. if(large<arr[j]) large = arr[j];
  26. } cout << large << "\n";
  27. }
  28. }
  29.  
  30.  
  31. return 0;
  32. }
Add Comment
Please, Sign In to add comment