Feedback for CS2023_STK problem

Problem Link: CS2023_STK Problem - CodeChef

Feedback

while submitting it shows run time error

@saurabhk23
Its working fine for me , can u send me your code?

include
include
using namespace std;
int maxOf(vector arr,int n){
int max = arr[0];
for(int i=0;i<=n;i++){
if(max<arr[i]){
max=arr[i];
}
}
return max;

}
int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
int b[n];
vector p={0};//to store count of a
vector q={0};//to store count of b

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int x=0;
    int y=0;
    for(int i=0;i<n;i++){
        if(a[i]>0){
            p[x]++;
        }
        if(a[i]==0){
            x++;
        }
        
    }
    for(int i=0;i<n;i++){
       if(b[i]>0){
            q[y]++;
        }
        if(b[i]==0){
            y++;
        }
    }
    
    int maxA=maxOf(p,x);
    int maxB=maxOf(q,y);
    if(maxA>maxB){
        cout<<"Om"<<endl;
    }
    if(maxB>maxA){
        cout<<"Addy"<<endl;
    }
    if(maxA==maxB){
        cout<<"Draw"<<endl;
    }
    
}
return 0;

}

@saurabhk23
i have corrected your some syntax error .
hope u will get it.

#include<bits/stdc++.h>
using namespace std;
int maxOf(vector<int> arr,int n){
int max = arr[0];
for(int i=0;i<=n;i++){
if(max<arr[i]){
max=arr[i];
}
}
return max;
}
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
int b[n];
vector<int> p(n,0);//to store count of a
vector<int> q(n,0);//to store count of b

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int x=0;
    int y=0;
    for(int i=0;i<n;i++){
        if(a[i]>0){
            p[x]++;
        }
        if(a[i]==0){
            x++;
        }
        
    }
    for(int i=0;i<n;i++){
       if(b[i]>0){
            q[y]++;
        }
        if(b[i]==0){
            y++;
        }
    }
    
    int maxA=maxOf(p,x);
    int maxB=maxOf(q,y);
    if(maxA>maxB){
        cout<<"Om"<<endl;
    }
    if(maxB>maxA){
        cout<<"Addy"<<endl;
    }
    if(maxA==maxB){
        cout<<"Draw"<<endl;
    }
    
}
return 0;
}