Created
January 6, 2022 08:30
-
-
Save RollingUpper/82cafe302b76a00f369c41c4b8ec5afd to your computer and use it in GitHub Desktop.
This file contains 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; | |
int closest = 500; | |
int dist = 0; | |
/** | |
* 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(); | |
for (int i = 0; i < n; i++) { | |
int t; // a temperature expressed as an integer ranging from -273 to 5526 | |
cin >> t; cin.ignore(); | |
int temp[i]; | |
temp[i] = t; | |
dist = t; | |
if (temp[i] == 0) { | |
cout << temp[i]; | |
} | |
else if (temp[i] < 0) { | |
for (int i = 0; dist < 0 ; i++) { | |
dist++; | |
} | |
} | |
if (temp[i] > 0) { | |
for (int i = 0; dist > 0; i++) { | |
dist--; | |
} | |
} | |
if (dist < closest){ | |
closest = temp[i]; | |
} | |
} | |
// Write an answer using cout. DON'T FORGET THE "<< endl" | |
// To debug: cerr << "Debug messages..." << endl; | |
cout << closest << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment