#include #define min(a, b) ((a) < (b) ? (a) : (b)) int main(void){ int i, n[7], yen[] = {500, 100, 50, 10, 5, 1}; for(i = 0; i < 7; ++i) { scanf("%d", &n[i]); } for(i = 0; i < 6; ++i) { int m = n[6] / yen[i]; n[6] -= yen[i] * min(m, n[i]); } if(n[6] == 0)printf("YES\n"); else printf("NO\n"); }