QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 10

#6579. Bazarek

统计

小比特正在奶奶巴图拉家度假。每天早上奶奶都会去市场购买一些产品。小男孩很快发现了一个有趣的规律:奶奶每天花在购物上的金额都是一个奇数整数。比特很快确定,这个规律是所有比特奶奶的共同特征。

每天,巴图拉奶奶在市场上的 $n$ 种产品中,每种最多购买一件。奶奶很节俭,不想带太多钱去购物。有一天,她问比特,如果她那天想在市场上购买正好 $k$ 种产品,她需要带多少钱。不幸的是,比特不知道奶奶打算买哪些产品,所以她带的钱必须足够购买任意 $k$ 种产品(以便它们总价格是奇数)。同样的情况重复发生了好几次。因此,比特决定系统地解决这个问题,编写一个程序,利用市场上所有产品的价格,来回答奶奶的问题。

输入

输入的第一行包含一个整数 $n$ ( $1 \le n \le 1,000,000$ ),表示市场上可用产品的数量。第二行包含 $n$ 个整数,范围在 $[1,10^9]$ 之间,表示各个产品的价格。这些数字以非递减顺序给出。

第三行包含一个整数 $m$ ( $1 \le m \le 1,000,000$ ),表示比特将与奶奶一起度过的剩余天数。接下来的 $m$ 行,每行包含一个整数 $k_i$ ( $1 \le k\_i \le n$ ),表示奶奶当天打算购买的产品数量。

输出

你的程序应该输出 $m$ 行。第 $i$ 行(对于 $i=1,\ldots,m$ )应该包含一个整数,表示 $k_i$ 种产品的最大奇数价格。如果无法选择 $k_i$ 种产品使总价格为奇数,则第 $i$ 行输出应为 $ -1 $。

示例

对于以下输入数据:

4
1 2 3 4
3
2
3
4

正确的输出是:

7
9
-1
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.