in the examples of first case there was no (2,3) why is it? there was (3,4) & (1,2)?
I am getting correct answer for all but task #11. Can anyone please tell what could i be possibly missing?
Link to my code:
https://www.codechef.com/viewsolution/9722785
//count subarray
include<bits/stdc++.h>
using namespace std;
int main()
{
long long int test,m,size,a[100000],count;
cin >> test;
while(testā)
{ cin >> size;
m = 0;
for(int i = 0;i < size;i++)
{ cin >> a[i];
}
count = 0;
for(int j = 0;j < size;j++)
{
if(a[j] <= a[j+1])
{ count++;
}
else
{ count++;
m = m + (count*(count+1))/2;
count = 0;
}
}
cout << m << endl;
}
return 0;
} please can anyone help me finding the error in this codeā¦ its passing all the testcases except the first 3 testcases
task # 11,12,13,14 gave WA. Code seems fine. Would anyone help me figure out boundary cases ? Thanks
hereās my code link text
this is my code,but its giving a test case WA in 3rd test case,can anyone please help me in itā¦
#include
#include
using namespace std;
int main()
{
int t;
cin>>t;
while(tā)
{
long int n,i,count=0,len=1,num=0;
cin>>n;
long int a[2000000];
for( i=0;i<n;i++)
{
cin>>a[i];
}
a[n]=0;
for(int i=0;i<n;i++)
{
if(a[i]<=a[i+1])
{
len++;
}
else
{
if(len>1)
{
int j = ((len)*(len-1))/2;
count=count+j;
}
len=1;
}
}
cout<<count+n<<"\n";
}
return 0;
}
I think the test cases are weak for this questions, My solution is O(n^2) with a little dynamic programming, but still passed all test cases and got 100 points. Shouldnāt O(n^2) give only 50 points?
Here is the link to my solution HI THERE.