/* -*- coding: utf-8 -*- * * 3065.cc: No.3065 Speedrun (Normal) - yukicoder */ #include #include #include using namespace std; /* constant */ const int M = 4; /* typedef */ using ll = long long; using pii = pair; /* global variables */ int as[M], ps[M]; pii pas[M]; /* subroutines */ /* main */ int main() { for (int i = 0; i < M; i++) scanf("%d", as + i); for (int i = 0; i < M; i++) scanf("%d", ps + i); ll t; scanf("%lld", &t); for (int i = 0; i < M; i++) pas[i] = {ps[i], as[i]}; sort(pas, pas + M); ll sum = 0; for (int i = 0; i < M; i++) { auto [pi, ai] = pas[i]; ll d = min(t / pi, (ll)ai); sum += d; t -= d * pi; } printf("%lld\n", sum); return 0; }