Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

largest good subarray - score 15% - what is the basis of scoring?

$
0
0

My code solves many test cases. But score is only 15%. May i know the method of scoring and code suggestion

Here is my code:

/************

Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world.

*************/

include <iostream>

int main() { int T, cols, k, i; //std::cout << "Number of test case " << std::endl; std::cin >> T; if(T>10) { return 0; } int good[T];

for(k=0;k<T;k++) {

    //std::cout << "Enter size of array " << std::endl;
    std::cin >> cols;
    if(cols > 100000) {
        return 0;
    }
    int i,j,m=0;
    int* matrix = new int[cols];

    //std::cout << "Enter Elements : " << std::endl;
    for(j=0;j<cols;j++) {
        std::cin >> matrix[j];
        if(matrix[j] > 1000000000) {
            return 0;
        }
    }

    /*for(j=0; j<cols;j++) {
        std::cout << "Element : " << j  << " : " << matrix[j] << "\n";
    }*/

    for(i=0; i<cols; i++) {
        for(j=i+1; j<cols;j++) {
            if(matrix[i] > matrix[j]) {
                if(j-i+1 > m) m=j-i+1;
            }
        }
    }

    good[k] = m;
    //std::cout << "Highest is : " << m << "\n";
}

for(i=0; i<T; i++) {
    std::cout << good[i] << "\n";
}
return 0;

}


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>