/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Accepted 2ms 764.0 KiB
#4 Time Exceeded ≥2099ms ≥552.0 KiB
#5 Time Exceeded ≥2097ms ≥1.637 MiB
#6 Time Exceeded ≥2099ms ≥1.43 MiB
#7 Time Exceeded ≥2099ms ≥592.0 KiB
#8 Time Exceeded ≥2100ms ≥1.43 MiB
#9 Time Exceeded ≥2099ms ≥1.637 MiB
#10 Time Exceeded ≥2101ms ≥1.641 MiB
#11 Accepted 67ms 532.0 KiB
#12 Accepted 132ms 532.0 KiB
#13 Accepted 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
    	int n,q,x;
    	cin >> n;
    	vector<int> a;
    	for(int i=0;i<n;i++){
    		int x;
    		cin >> x;
    		a.push_back(x);
    	}
    	cin >> q;
    	vector<int> b;
    	for(int i=0;i<q;i++){
    		int x;
    		cin >> x;
    		b.push_back(x);
    	}
    	for(int i=0;i<q;i++){
    		int c = 0;
    		int qindex = b[i];
    		//cout << "query index = " << qindex-1 << " : " << a[qindex-1] << endl;
    		for(int j=0;j<=qindex-1;j++){
    			for(int k=qindex;k<=n-1;k++){
    				//cout << a[j] << " " << a[qindex-1] << " " << a[k] << endl;
    				if((a[j] > a[qindex-1] && a[qindex-1] > a[k]) || (a[j] < a[qindex-1] && a[qindex-1] < a[k]))
    					c++;
    			}
    		}
    		cout << c << endl;
    	}
    	
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1079 Roy and Query (Easy Version)
Contest
Brain Booster #6
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 17:01:32
Judged At
2024-10-03 17:01:32
Judged By
Score
44
Total Time
≥2101ms
Peak Memory
≥1.641 MiB