NOIP2016复赛真题——买铅笔_#include

//Author:PanDaoxi
#include <iostream>
using namespace std;
struct pencil{
	int money,bar,total;
} pen[3];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<3;i++){
		cin>>pen[i].bar>>pen[i].money;
		if(n%pen[i].bar) pen[i].total=(n/pen[i].bar+1)*pen[i].money;
		else pen[i].total=(n/pen[i].bar)*pen[i].money;
	}
	int x=pen[0].total;
	for(int i=0;i<3;i++){
		if(x>pen[i].total) x=pen[i].total;
	}
	cout<<x<<endl;
	return 0;
}