Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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();
- int temps[n];
- int mark;
- for (int i = 0; i < n; i++) cin >> temps[i];
- sort(temps, temps+n);
- for (int i = 0; i < n; i++)
- {
- if (temps[i] > 0)
- {
- mark = i;
- break;
- }
- }
- if (mark == 0) mark = n-1;
- if (n == 0) cout << n << endl;
- else if (temps[0] == 0 || temps[0] == 1) cout << temps[0] << endl;
- else if (n == 1) cout << temps[0] << endl;
- else if (-1 * temps[mark-1] < temps[mark]) cout << temps[mark-1] << endl;
- else cout << temps[mark] << endl;
- // cout << "result" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement