#include "bits/stdc++.h" using namespace std; void solve(void) { int cs[7], ds[] = {500, 100, 50, 10, 5, 1}; for (int i = 0; i < 7; i++) { cin >> cs[i]; } for (int i = 0; i < 6; i++) { if (cs[i]) { int x = min(cs[6] / cs[i], ds[i]); cs[6] -= x * cs[i]; } } cout << (cs[6] ? "NO" : "YES") << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }