Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Created August 9, 2017 09:30
Show Gist options
  • Save MohamedTaha98/1dbd246d5fd28b406ea9cd91320d6636 to your computer and use it in GitHub Desktop.
Save MohamedTaha98/1dbd246d5fd28b406ea9cd91320d6636 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int a, b;
double c;
while (true) {
bool test = true;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0)
return 0;
double wid[a], len[b];
for (int i = 0; i < a; i++)
cin >> wid[i];
for (int i = 0; i < b; i++)
cin >> len[i];
sort (wid, wid + a);
sort (len, len + b);
if (wid[0] > (c / 2) || len[0] > (c / 2))
test = false;
else if (75 - wid[a - 1] > (c / 2) || 100 - len[b - 1] > (c / 2))
test = false;
else {
for (int i = 0; i < a - 1; i++) {
if (wid[i + 1] - wid[i] > c)
test = false;
}
if (test == true) {
for (int i = 0; i < b - 1; i++) {
if (len[i + 1] - len[i] > c)
test = false;
}
}
}
if (test == true)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment