لینک‌های مفید برای شرکت در مسابقه:

توجه کنید که سوالات مسابقه ترتیب خاصی ندارند.

A: Cake



A rectangular cake is transported via a truck to a restaurant. On the way to the destination, the truck hits a pothole, which shatters the cake in NN perfectly rectangular pieces of width wiw_i and length lil_i, for 1iN1 \le i \le N.

At the destination, the damage is assessed, and the customer decides to order a replacement cake of the same dimensions. Unfortunately, the original order form was incompletely filled and only the width WW of the cake is known. The restaurant asks for your help to find out the length LL of the cake.

Fortunately, all pieces of the cake have been kept.

Input🔗

The input consists of the following integers:

  • on the first line, the width WW of the cake;
  • on the second line, the number NN of shattered pieces;
  • on each of the next NN lines, the width wiw_i and length lil_i of each piece.

1N50000001 \le N \le 5000000 1W,L100001 \le W, L \le 10000 1wi,li100001 \le w_i, l_i \le 10000

Output🔗

The output should be the integer LL.

Sample Input🔗

4
7
2 3
1 4
1 2
1 2
2 2
2 2
2 1
Plain text

Sample Output🔗

6
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.