AT_abc465_f.Sjeltzer?
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A certain refrigerator assigns each drink a 6-digit numeric string as its ID.
This refrigerator stores N drinks. The i-th drink has ID Si and size Vi. S1,…,SN are distinct.
Answer Q queries. Each query is given in the form of 6-digit numeric strings x,y, and asks the following.
- Among the drinks stored in this refrigerator, find the sum of the sizes of those whose assigned ID s satisfies the following for every k=1,…,6.
- xk≤sk≤yk, where sk,xk,yk denote the values represented by the k-th digits of s,x,y, respectively.
某台冰箱为每瓶饮料分配一个 6 位数字字符串作为其 ID。
该冰箱共存储 N 瓶饮料。第 i 瓶饮料的 ID 为 Si,体积为 Vi。S1,…,SN 互不相同。
回答 Q 个查询。每个查询给出两个 6 位数字字符串 x 和 y,要求如下:
- 在该冰箱所存储的饮料中,找出所有满足如下条件的饮料,并求它们的体积之和:
- 对于每个 k=1,…,6,均有 xk≤sk≤yk,其中 sk,xk,yk 分别表示字符串 s,x,y 的第 k 位数字所代表的数值。
输入格式
The input is given from Standard Input in the following format:
N
S1 V1
…
SN VN
Q
query1
⋮
queryQ
Here, queryq is the q-th query, given in the following format:
x y
输入从标准输入给出,格式如下:
N
S1 V1
…
SN VN
Q
query1
⋮
queryQ
其中,queryq 表示第 q 个查询,其格式如下:
x y
输出格式
Output Q lines. The q-th line should contain the answer to the q-th query.
输出 Q 行。第 q 行应包含第 q 个查询的答案。
输入输出样例
输入#1
5 000000 1 314159 2 161803 10 169231 5 384400 20 4 150001 269944 302010 396939 000000 999999 999000 000444
输出#1
15 0 38 0
输入#2
8 778722 12744734 488742 359266786 955942 335004463 454854 331175626 934246 179761526 927777 657312747 652568 109900930 753279 405123850 8 201000 785589 202325 955898 310401 875947 044023 988999 111230 567897 133241 577989 101033 999499 453013 796988
输出#2
515024780 109900930 0 331175626 331175626 331175626 584885376 331175626
说明/提示
Sample 1 Explanation:
For the first query, the drinks satisfying the condition are the third and fourth drinks.
For the second query, no drinks satisfy the condition.
For the third query, the drinks satisfying the condition are the first, second, third, fourth, and fifth drinks.
For the fourth query, no drinks satisfy the condition.
Constraints
- N is an integer.
- 1≤N≤3×105
- Si is a string consisting of digits (
0-9). - ∣Si∣=6
- S1,…,SN are distinct.
- Vi is an integer.
- 1≤Vi≤109
- Q is an integer.
- 1≤Q≤3×105
- In each query, x and y are strings consisting of digits (
0-9). - In each query, ∣x∣=∣y∣=6.
样例 1 解释:
对于第一个查询,满足条件的饮品是第三种和第四种饮品。
对于第二个查询,没有饮品满足条件。
对于第三个查询,满足条件的饮品是第一种、第二种、第三种、第四种和第五种饮品。
对于第四个查询,没有饮品满足条件。
约束条件
- N 是一个整数。
- 1≤N≤3×105
- Si 是一个仅由数字(
0–9)组成的字符串。 - ∣Si∣=6
- S1,…,SN 互不相同。
- Vi 是一个整数。
- 1≤Vi≤109
- Q 是一个整数。
- 1≤Q≤3×105
- 在每次查询中,x 和 y 均为仅由数字(
0–9)组成的字符串。 - 在每次查询中,∣x∣=∣y∣=6
输入解题思路,AI测评打分。不知道怎么写?