Created
December 1, 2018 20:46
-
-
Save Zolomon/ff4a7e0ad95d24f659d1e5253ef931d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() | |
{ | |
std::vector<int> temperatures; | |
int n; // the number of temperatures to analyse | |
cin >> n; cin.ignore(); | |
for (int i = 0; i < n; i++) { | |
int t; // a temperature expressed as an integer ranging from -273 to 5526 | |
cin >> t; cin.ignore(); | |
temperatures.push_back(t); | |
} | |
auto closest_to_zero = [](int l, int r) { | |
return abs(l) > abs(r); | |
}; | |
std::sort(temperatures.begin(), temperatures.end(), closest_to_zero); | |
// Write an action using cout. DON'T FORGET THE "<< endl" | |
// To debug: cerr << "Debug messages..." << endl; | |
cout << temperatures.back() << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment