Wrong Answer
Code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i=0; i<n; i++)
{
cin>>a[i];
}
int q;
cin>>q;
while(q--){
int x;
cin>>x;
x--;
int cls=0, clg=0, crs=0, crg=0;
for(int i=0; i<x; i++)
{
if(a[i]<a[x]){
cls++;
}
else{
clg++;
}
}
for(int k=x+1; k<n; k++)
{
if(a[k]<a[x]){
crs++;
}
else{
crg++;
}
}
int rst = (clg*crs)+(cls*crg);
cout<<rst<<endl;
}
}
}
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:58:05
- Judged At
- 2024-11-11 02:45:17
- Judged By
- Score
- 4
- Total Time
- 2ms
- Peak Memory
- 536.0 KiB