problem id:-https://www.codechef.com/MAY17/problems/MXMEDIAN
code:--
//it works good for small test case but not for large test case
// wait till we upload the optimized code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int num;
int max=0;
for(int i=0;i<n;++i)
{
cin>>num;
if(max<num)
max=num;
}
cout<<n-max<<'\n';
}
return 0;
}
code:--
//it works good for small test case but not for large test case
// wait till we upload the optimized code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int num;
int max=0;
for(int i=0;i<n;++i)
{
cin>>num;
if(max<num)
max=num;
}
cout<<n-max<<'\n';
}
return 0;
}
No comments:
Post a Comment