Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
48620769 Contestant:
choudhary0007
1105A - 57 C++14 (GCC 6-32) Wrong answer on test 26 31 ms 4 KB 2019-01-20 15:41:12 2019-01-20 17:37:41
→ Source
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n;
	cin>>n;
	int a[n+1];
	int min=INT_MAX;
	int max=INT_MIN;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(min>a[i])
		    min=a[i];
		if(max<a[i])
		    max=a[i];    
	}
	int i,t;
	int s[n+1];
	for(t=min;t<=max;t++)
	{
		int l[n+1];
		for(i=1;i<=n;i++)
		{
			if(a[i]==t)
			   l[i]=0;
			else if(a[i]>t)
			          l[i]=abs(a[i]-t-1);
				else
				    l[i]=abs(a[i]-t+1);	     
		}
		int sum=0;
		for(i=1;i<=n;i++)
		{
			sum=sum+l[i];
		}
		s[t]=sum;
	}
	int p=INT_MAX,j;
	for(i=min;i<=max;i++)
	{
		if(p>s[i])
		{
		   p=s[i];
		   j=i;
	    }
	}
	cout<<j<<" "<<p;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details