/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 2ms 324.0 KiB
#4 Time Exceeded ≥2093ms ≥784.0 KiB
#5 Time Exceeded ≥2078ms ≥1.574 MiB

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-11-11 02:46:54
Judged By
Score
20
Total Time
≥2093ms
Peak Memory
≥1.574 MiB