mirror of
https://github.com/mx42/codingame.git
synced 2026-01-14 05:39:51 +01:00
Adding easy puzzles
This commit is contained in:
47
puzzles/easy/temperatures.cpp
Normal file
47
puzzles/easy/temperatures.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// https://www.codingame.com/ide/puzzle/temperatures
|
||||
// Xavier Morel - 2014-10-16
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Auto-generated code below aims at helping you parse
|
||||
* the standard input according to the problem statement.
|
||||
**/
|
||||
int main()
|
||||
{
|
||||
int N; // the number of temperatures to analyse
|
||||
cin >> N; cin.ignore();
|
||||
|
||||
|
||||
|
||||
// Write an action using cout. DON'T FORGET THE "<< endl"
|
||||
// To debug: cerr << "Debug messages..." << endl;
|
||||
|
||||
if (N == 0) {
|
||||
cout << "0";
|
||||
} else {
|
||||
int minTemp;
|
||||
for (int i = 0; i < N; i++) {
|
||||
int temp;
|
||||
cin >> temp;
|
||||
|
||||
if (i == 0) {
|
||||
minTemp = temp;
|
||||
} else if (
|
||||
((temp * temp) < (minTemp * minTemp)) || (
|
||||
(temp * temp) == (minTemp * minTemp) && minTemp < temp
|
||||
)
|
||||
) {
|
||||
minTemp = temp;
|
||||
}
|
||||
}
|
||||
|
||||
cout << minTemp;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
Reference in New Issue
Block a user