#include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { const int n = 6; int p[n]; for (int i = 0; i < n; i++) { cin >> p[i]; } int g; cin >> g; int c[n] = { 500, 100, 50, 10, 5, 1 }; for (int i = 0; i < n; i++) { int k = min(p[i], g / c[i]); g -= k * c[i]; } cout << (g == 0 ? "YES" : "NO") << endl; return 0; }