【BestCoder】#34

1001 Go to movie

水。

#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <set>
using namespace std;


#define read() freopen("data.in", "r", stdin)
#define write() freopen("data.out", "w", stdout)
#define clr( a , x ) memset ( a , x , sizeof a )  
#define cpy( a , x ) memcpy ( a , x , sizeof a ) 
#define _max(a,b) ((a>b)?(a):(b))
#define _min(a,b) ((a<b)?(a):(b))
#define LL long long 
const int maxNumber=10002;


int main()
{
	//read();
	int i;
	int n,m;
	int a,b;
	int sum[200];
	while(cin>>n>>m)
	{
		//clr(sum,0);
		for (i = 0; i < m; ++i)
		{
			cin>>a>>b;
			if (n%a==0)
			{
				sum[i] = (n/a*b);
				
			}else
			{
				sum[i] = (((n/a)+1)*b);
			}
		}
		sort(sum,sum+m);
		cout<<sum[0]<<endl;
	}
    return 0;
   
}

  

posted @ 2015-03-21 23:04  Summer先生  阅读(117)  评论(0编辑  收藏  举报