#include using namespace std; constexpr int cost[6] = {500, 100, 50, 10, 5, 1}; bool dp[10][100005]; int main(){ vector cnt(6); int g; for(int i = 0; i < 6; ++i) cin >> cnt[i]; cin >> g; dp[0][0] = true; for(int i = 0; i < 6; ++i){ int ub = cnt[i]; for(int j = 0; j <= g; ++j){ if(!dp[i][j]) continue; for(int k = 0; k <= ub; ++k){ int add = cost[i] * k; dp[i + 1][j + add] = true; } } } if(dp[6][g]) cout << "YES\n"; else cout << "NO\n"; }