#713
Unrated
True or False Test
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Note: The time limit for this problem is 3s, 1.5x the default. The memory limit for this problem is 512MB, twice the default.

Bessie is taking an NN-question true or false test (1N21051\le N\le 2\cdot 10^5). For the ii-th question, she will gain aia_i points if she gets it correct, lose bib_i points if she gets it incorrect, or remain even if she does not answer it (0<ai,bi1090<a_i,b_i\le 10^9).

Bessie knows all the answers because she is a smart cow, but worries that Elsie (who is administering the test) will retroactively change up to kk of the questions after the test such that Bessie does not get those questions correct.

Given QQ (1QN+11\le Q\le N+1) candidate values of kk (0kN0\le k\le N), determine the number of points Bessie can guarantee for each kk, given that she must answer at least kk questions.

입력

The first line contains NN and QQ.

The next NN lines each contain aia_i and bib_i.

The next QQ lines each contain a value of kk. No value of kk appears more than once.

출력

The answer for each kk on a separate line.

예제 입력 1

2 3
3 1
4 2
2
1
0

예제 출력 1

-3
1
7

점수

Inputs 2-4: N100N\le 100Inputs 5-7: Q10Q\le 10, N2105N\le 2\cdot 10^5Inputs 7-20: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.