Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Make them equal codechef solution in c++

/*
   problem link: https://www.codechef.com/LP1TO202/problems/MAKEEQUAL
*/

#include<iostream>
#include<climits>
#define ll long long
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;

void solve()
{
	ll n;
	cin >> n;
	vector<ll> v(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	ll mn = INT_MAX, mx = INT_MIN;
	for (ll i = 0; i < n; i++)
	{
		mn = min(mn, v[i]);
		mx = max(mx, v[i]);
	}
	cout << mx - mn << "
";
}

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: warning in range-based for loop in C++. How to resolve it in vscode? 
Cpp :: operazioni aritmetiche c++ 
Cpp :: c++ set value to inf 
Cpp :: algorithm map values 
Cpp :: sort array using stl 
Cpp :: Use command line arguments to create file c++ 
Cpp :: 1047. Remove All Adjacent Duplicates In String solution leetcode in c++ 
Cpp :: c++ FAILED: objekt aufruf : symbol(s) not found for architecture x86_64 
Cpp :: deal with bad input cpp 
Cpp :: convert char to C 
Cpp :: c++ loop through an array 
Cpp :: beecrowd problem 1004 solution 
Cpp :: unreal ensureMsgf example 
Cpp :: clang does not recognize std::cout 
Cpp :: how to list directory in c++ 
Cpp :: & before function arg in cpp 
Cpp :: how to display score using SDL in c++ 
Cpp :: qt/c++ exception handler 
Cpp :: C++ 4.3.2 (gcc-4.3.2) sample 
Cpp :: c++ to c converter 
Cpp :: c++ compile to msi 
Cpp :: operator = overloading c++ 
Cpp :: c++ is nan 
Cpp :: c++ variables 
Cpp :: Fibonacci Series Program. in c++ 
Cpp :: program to check smallest num in three numbers in c++ 
Cpp :: qt graphics scene map cursor position 
C :: myFgets in c 
C :: arma 3 get group size 
C :: vowel or consonant in c 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =