Search

# Hacker Rank solution for Preprocessor Solution In C++

#define toStr(x) #x

#define io(v) cin >> v

#define INF 100000000

#define foreach(v, i) for(int i = 0; i < v.size(); i++)

#define FUNCTION(name, op) void name(int& a, int b) { if (b op a) a = b; }

#include <iostream>

#include <vector>

using namespace std;

#if !defined toStr || !defined io || !defined FUNCTION || !defined INF

#error Missing preprocessor definitions

FUNCTION(minimum, <)

FUNCTION(maximum, >)

int main(){

int n; cin >> n;

vector<int> v(n);

foreach(v, i) {

io(v)[i];

}

int mn = INF;

int mx = -INF;

foreach(v, i) {

minimum(mn, v[i]);

maximum(mx, v[i]);

}

int ans = mx - mn;

cout << toStr(Result =) <<' '<< ans;

return 0;

}

### Recent Posts

See All

#### Solubility - CodeChef Solution in Java and C++| AskTheCode

CodeChef May Long Challenge Solution | Solubility (SOLBLTY) solution | AskTheCode Solubility (SOLBLTY) solution Problem: Suppose for a unit rise in temperature, the solubility of sugar in water increa

#### Valid Paths CodeChef Solution in C++ | AskTheCode

CodeChef May Long Challenge Solution | Valid Paths (VPATH) solution | AskTheCode Valid Paths (VPATH) CodeChef solution Problem: You are given a tree with N nodes numbered from 1 to N. A set S of nodes

#### Modular Equation CodeChef May Long Challenge 2021 Soution | AskTheCode

CodeChef May Long Challenge Solution | Modular Equation (MODEQ) solution | AskTheCode Modular Equation (MODEQ) solution Problem: Given integers N and M, find the number of ordered pairs (a,b) such tha