CF2230E.Minimum Influence

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Imagine that you are the owner of a news website and want to study how some selected news items affect your users.

You have nn news items, and for each of them, you have already determined two parameters: how much it touches politics pip_i and how much it touches culture cic_i.

You also have mm users whose reaction to the news you want to study. For each person, you have already determined three parameters: tolerance to political news tpjtp_j, tolerance to cultural news tcjtc_j, and the "zone of influence" djd_j.

The influence of politics Ip(i,j)I_p(i, j) and culture Ic(i,j)I_c(i, j) in news item ii on user jj can be calculated by the following formulas:

\\begin{array}{ c c } I\_p(i, j) = \\begin{cases} 0 & \\text{if } p\_i \\lt tp\_j \\\\ p\_i & \\text{if } tp\_j \\le p\_i \\lt tp\_j + d\_j \\\\ tp\_j + d\_j & \\text{if } p\_i \\ge tp\_j + d\_j \\end{cases}, & I\_c(i, j) = \\begin{cases} 0 & \\text{if } c\_i \\lt tc\_j \\\\ c\_i & \\text{if } tc\_j \\le c\_i \\lt tc\_j + d\_j \\\\ tc\_j + d\_j & \\text{if } c\_i \\ge tc\_j + d\_j \\end{cases} \\end{array}.

In other words, while the amount of politics pip_i is less than the tolerance level tpjtp_j, it does not affect the user. Otherwise, the topic starts to irritate the user, but not more than up to tpj+djtp_j + d_j. The same goes for culture.

The total influence of news item ii on user jj is I(i,j)=Ip(i,j)+Ic(i,j)I(i, j) = I_p(i, j) + I_c(i, j).

For each user jj, determine the minimum influence I(i,j)I(i, j) among all news items ii.

假设你是某新闻网站的所有者,希望研究若干选定的新闻条目对用户的影响。

你共有 nn 条新闻,对每条新闻 ii,你已预先确定两个参数:其政治相关度 pip_i 和文化相关度 cic_i。

你还拥有 mm 名用户,希望研究他们对这些新闻的反应。对每位用户 jj,你已预先确定三个参数:其对政治类新闻的容忍度 tpjtp_j、对文化类新闻的容忍度 tcjtc_j,以及“影响区间” djd_j。

新闻条目 ii 对用户 jj 在政治方面的影响 Ip(i,j)I_p(i, j) 和在文化方面的影响 Ic(i,j)I_c(i, j) 可由以下公式计算:

I_p(i,j)={0if p_i<tp_jp_iif tp_j≤p_i<tp_j+d_jtp_j+d_jif p_i≥tp_j+d_j,I_c(i,j)={0if c_i<tc_jc_iif tc_j≤c_i<tc_j+d_jtc_j+d_jif c_i≥tc_j+d_j.\begin{array}{ c c } I\_p(i, j) = \begin{cases} 0 & \text{if } p\_i \lt tp\_j \\ p\_i & \text{if } tp\_j \le p\_i \lt tp\_j + d\_j \\ tp\_j + d\_j & \text{if } p\_i \ge tp\_j + d\_j \end{cases}, & I\_c(i, j) = \begin{cases} 0 & \text{if } c\_i \lt tc\_j \\ c\_i & \text{if } tc\_j \le c\_i \lt tc\_j + d\_j \\ tc\_j + d\_j & \text{if } c\_i \ge tc\_j + d\_j \end{cases} \end{array}.

换言之,当政治相关度 pip_i 小于容忍度 tpjtp_j 时,该新闻不会对用户产生影响;否则,该主题开始令用户感到不适,但其影响上限为 tpj+djtp_j + d_j。文化相关度同理。

新闻条目 ii 对用户 jj 的总影响定义为 I(i,j)=Ip(i,j)+Ic(i,j)I(i, j) = I_p(i, j) + I_c(i, j)。

对每位用户 jj,请找出其受所有新闻条目 ii 影响的最小总影响值 I(i,j)I(i, j)。

输入格式

The first line contains one integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of news items.

The second line contains nn integers p1,p2,…,pnp_1, p_2, \dots, p_n (0≤pi≤1060 \le p_i \le 10^6) — the amount of political content of each news item.

The third line contains nn integers c1,c2,…,cnc_1, c_2, \dots, c_n (0≤ci≤1060 \le c_i \le 10^6) — the amount of cultural content of each news item.

The fourth line contains one integer mm (1≤m≤4⋅1051 \le m \le 4 \cdot 10^5) — the number of users.

The fifth line contains mm integers tp1,tp2,…,tpmtp_1, tp_2, \dots, tp_m (0≤tpj≤1060 \le tp_j \le 10^6) — the political tolerance of each user.

The sixth line contains mm integers tc1,tc2,…,tcmtc_1, tc_2, \dots, tc_m (0≤tcj≤1060 \le tc_j \le 10^6) — the cultural tolerance of each user.

The seventh line contains mm integers d1,d2,…,dmd_1, d_2, \dots, d_m (0≤dj≤1060 \le d_j \le 10^6) — the zone of influence of each user.

第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 新闻条目的数量。

第二行包含 nn 个整数 p1,p2,…,pnp_1, p_2, \dots, p_n(0≤pi≤1060 \le p_i \le 10^6)—— 每条新闻的政治内容量。

第三行包含 nn 个整数 c1,c2,…,cnc_1, c_2, \dots, c_n(0≤ci≤1060 \le c_i \le 10^6)—— 每条新闻的文化内容量。

第四行包含一个整数 mm(1≤m≤4⋅1051 \le m \le 4 \cdot 10^5)—— 用户的数量。

第五行包含 mm 个整数 tp1,tp2,…,tpmtp_1, tp_2, \dots, tp_m(0≤tpj≤1060 \le tp_j \le 10^6)—— 每个用户的政治理解度。

第六行包含 mm 个整数 tc1,tc2,…,tcmtc_1, tc_2, \dots, tc_m(0≤tcj≤1060 \le tc_j \le 10^6)—— 每个用户的文化理解度。

第七行包含 mm 个整数 d1,d2,…,dmd_1, d_2, \dots, d_m(0≤dj≤1060 \le d_j \le 10^6)—— 每个用户的影响力范围。

输出格式

For each user, output one integer — the minimum influence I(i,j)I(i, j) among all news items.

对每个用户,输出一个整数——所有新闻项中最小的影响值 I(i,j)I(i, j)。

输入输出样例

  • 输入#1

    6
    2 4 1 6 0 10
    3 2 6 1 9 0
    5
    0 0 0 1 5
    0 0 9 5 2
    9 4 8 2 2

    输出#1

    5
    4
    1
    2
    2
  • 输入#2

    5
    75 19 53 12 10
    34 75 67 84 95
    5
    55 14 46 97 14
    78 61 56 23 33
    10 4 7 11 3

    输出#2

    0
    18
    53
    34
    36

说明/提示

null

输入解题思路,AI测评打分。不知道怎么写?

首页