Solution for DMOPC '19 Contest 1 P0 - Range Finding in C++


May 4, 2020 0.416426 seconds C++
#include <bits/stdc++.h>
using namespace std;


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, l = 0, s = 1000000, t;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t;
		if(t > l){
			l = t;
		}else if(t < s){
			s = t;
		}
	}

	cout << l - s;

	return 0;
}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.