Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int arr[100005];
- int main() {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- /*---------------------------------------------------------------------------------*/
- ll T, n, Q, a, large;
- cin >> T;
- while(T--)
- {
- cin >> n >> Q;
- for(ll i=0; i<n; i++) cin >>arr[i];
- while(Q--)
- {
- cin >> a;
- large = arr[0];
- for(ll j = 0; j<a; j++) {
- if(large<arr[j]) large = arr[j];
- } cout << large << "\n";
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment