QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100

#10966. True or False Test

統計

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 $N$-question true or false test ($1\le N\le 2\cdot 10^5$). For the $i$-th question, she will gain $a_i$ points if she gets it correct, lose $b_i$ points if she gets it incorrect, or remain even if she does not answer it ($0 < 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 $k$ of the questions after the test such that Bessie does not get those questions correct. Given $Q$ ($1\le Q\le N+1$) candidate values of $k$ ($0\le k\le N$), determine the number of points Bessie can guarantee for each $k$, given that she must answer at least $k$ questions.

Input Format

The next $N$ lines each contain $a_i$ and $b_i$. The next $Q$ lines each contain a value of $k$. No value of $k$ appears more than once.

The next $Q$ lines each contain a value of $k$. No value of $k$ appears more than once.

Output Format

The answer for each $k$ on a separate line.

Sample Data

Sample Input

2 3
3 1
4 2
2
1
0

Sample Output

-3
1
7

Sample Explanation

For each value of $k$, it is optimal for Bessie to answer all of the questions.

Constraints

  • Inputs 2-4: $N\le 100$
  • Inputs 5-7: $Q\le 10$, $N\le 2\cdot 10^5$
  • Inputs 7-20: No additional constraints.
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.