Last active
December 31, 2016 15:58
-
-
Save cubedtear/01741de64398f2103cdd70237dd9f53f 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 <vector> | |
#include <algorithm> | |
using namespace std; | |
struct sort_pred { | |
bool operator()(const std::pair<int, int> &left, const std::pair<int, int> &right) { | |
return left.first == right.first ? left.second < right.second : left.first < right.first; | |
} | |
}; | |
int main() { | |
while (true) { | |
int cityCount; | |
cin >> cityCount; | |
if (cityCount == 0) break; | |
vector<pair<int, int> > cities; | |
for (int i = 0; i < cityCount; i++) { | |
int inv, earn; | |
cin >> inv >> earn; | |
cities.push_back(make_pair(inv, earn)); | |
} | |
sort(cities.begin(), cities.end(), sort_pred()); | |
bool done = false; | |
for (std::vector<pair<int, int> >::iterator i = cities.begin(); i != cities.end();i++) { | |
auto next = i; | |
next++; | |
if (next != cities.end() && next->first > i->first && next->second <= i->second) { | |
cout << "NO\n"; | |
done = true; | |
break; | |
} | |
} | |
if (!done) cout << "SI\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment