/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 504.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Wrong Answer 2ms 536.0 KiB

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