알고리즘문제들/codingame
Temperatures
Beabletoet
2018. 2. 21. 17:52
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { int n, p = 5527, m = -5527, result; cin >> n; cin.ignore(); for (int i = 0; i < n; i++) { int t; cin >> t; cin.ignore(); if(t>0) p = (t<p) ? t : p; else m = (t>m) ? t : m; } if(p == 5527 && m == -5527) result = 0; else result = (p > (m*(-1))) ? m : p; cout << result << endl; } | cs |