#include #define PI 3.14159265359 using namespace std; int main() { vector v1(6), v2(6); v1 = { 500,100,50,10,5,1 }; for (int i = 0; i < 6; i++) { cin >> v2.at(i); } int G; cin >> G; int n; bool b = false; for (int i = 0; i < 6; i++) { int& n1 = v1.at(i), & n2 = v2.at(i); while (n2) { if (G >= n1) { G -= n1; n2--; } else { break; } } if (G == 0) { b = true; break; } } cout << (b ? "YES" : "NO") << endl; }