#include #include #include using namespace std; int main() { vector>problem(4); long long t; for(int i=0;i<4;i++)cin >> problem[i].second; for(int i=0;i<4;i++)cin >> problem[i].first; cin >> t; sort(problem.begin(),problem.end()); long long ans=0; for(int i=0;i<4;i++){ if(t/problem[i].first>=problem[i].second){ ans+=problem[i].second; t-=problem[i].first*problem[i].second; } else{ ans+=t/problem[i].first; break; } } cout << ans << endl; }