Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bismillahir Rahmanir Rahim
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- scanf("%d", &t);
- int z;
- for(z = 1; z <= t; z++){
- int n, k;
- scanf("%d %d", &n, &k);
- int i, temp;
- vector<int> vec;
- for(i = 1; i <= n; i++){
- scanf("%d", &temp);
- vec.push_back(temp);
- }
- //code for checking attempts.
- int first, last;
- printf("Case %d:\n", z);
- int ans = 0;
- for(i = 1; i <= k; i++){
- scanf("%d %d",&first, &last);
- vector <int> vec2;
- vec2 = vec;
- int j;
- if(first != last){
- for(j = first - 1; j < last - 1; j++){
- if(vec2[j] < vec2[j + 1]){
- int x;
- x = vec2[j];
- vec2[j] = vec2[j+1];
- vec2[j+1] = x;
- }
- }
- ans = vec2[last - 1];
- }
- else ans = vec2[first - 1];
- printf("%d\n", ans);
- /*for(it = vec2.begin(); it != vec2.end(); it++){
- cout << *it << endl;
- } */
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement