CF1914D.Three Activities

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Winter holidays are coming up. They are going to last for nn days.

During the holidays, Monocarp wants to try all of these activities exactly once with his friends:

  • go skiing;
  • watch a movie in a cinema;
  • play board games.

Monocarp knows that, on the ii-th day, exactly aia_i friends will join him for skiing, bib_i friends will join him for a movie and cic_i friends will join him for board games.

Monocarp also knows that he can't try more than one activity in a single day.

Thus, he asks you to help him choose three distinct days x,y,zx, y, z in such a way that the total number of friends to join him for the activities (ax+by+cza_x + b_y + c_z) is maximized.

寒假即将到来,假期将持续 nn 天。

在此期间,Monocarp 想要和朋友们恰好各体验一次以下三项活动:

  • 去滑雪;
  • 去电影院看电影;
  • 玩桌游。

Monocarp 已知:在第 ii 天,恰好有 aia_i 位朋友陪他去滑雪,bib_i 位朋友陪他去看电影,cic_i 位朋友陪他玩桌游。

Monocarp 还知道,他每天最多只能进行一项活动。

因此,他请你帮他选出三个互不相同的日期 x,y,zx, y, z,使得参与这三项活动的朋友总人数(即 ax+by+cza_x + b_y + c_z)最大化。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains a single integer nn (3≤n≤1053 \le n \le 10^5) — the duration of the winter holidays in days.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1081 \le a_i \le 10^8) — the number of friends that will join Monocarp for skiing on the ii-th day.

The third line contains nn integers b1,b2,…,bnb_1, b_2, \dots, b_n (1≤bi≤1081 \le b_i \le 10^8) — the number of friends that will join Monocarp for a movie on the ii-th day.

The fourth line contains nn integers c1,c2,…,cnc_1, c_2, \dots, c_n (1≤ci≤1081 \le c_i \le 10^8) — the number of friends that will join Monocarp for board games on the ii-th day.

The sum of nn over all testcases doesn't exceed 10510^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)——测试用例的数量。

每个测试用例的第一行包含一个整数 nn(3≤n≤1053 \le n \le 10^5)——寒假的持续天数。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1081 \le a_i \le 10^8)——第 ii 天将与 Monocarp 一起滑雪的朋友人数。

第三行包含 nn 个整数 b1,b2,…,bnb_1, b_2, \dots, b_n(1≤bi≤1081 \le b_i \le 10^8)——第 ii 天将与 Monocarp 一起看电影的朋友人数。

第四行包含 nn 个整数 c1,c2,…,cnc_1, c_2, \dots, c_n(1≤ci≤1081 \le c_i \le 10^8)——第 ii 天将与 Monocarp 一起玩桌游的朋友人数。

所有测试用例的 nn 值之和不超过 10510^5。

输出格式

For each testcase, print a single integer — the maximum total number of friends that can join Monocarp for the activities on three distinct days.

对于每个测试用例,输出一个整数——即最多能与 Monocarp 一起参加这三天不同活动的朋友总数。

输入输出样例

  • 输入#1

    4
    3
    1 10 1
    10 1 1
    1 1 10
    4
    30 20 10 1
    30 5 15 20
    30 25 10 10
    10
    5 19 12 3 18 18 6 17 10 13
    15 17 19 11 16 3 11 17 17 17
    1 17 18 10 15 8 17 3 13 12
    10
    17 5 4 18 12 4 11 2 16 16
    8 4 14 19 3 12 6 7 5 16
    3 4 8 11 10 8 10 2 20 3

    输出#1

    30
    75
    55
    56

说明/提示

In the first testcase, Monocarp can choose day 22 for skiing, day 11 for a movie and day 33 for board games. This way, a2=10a_2 = 10 friends will join him for skiing, b1=10b_1 = 10 friends will join him for a movie and c3=10c_3 = 10 friends will join him for board games. The total number of friends is 3030.

In the second testcase, Monocarp can choose day 11 for skiing, day 44 for a movie and day 22 for board games. 30+20+25=7530 + 20 + 25 = 75 friends in total. Note that Monocarp can't choose day 11 for all activities, because he can't try more than one activity in a single day.

In the third testcase, Monocarp can choose day 22 for skiing, day 33 for a movie and day 77 for board games. 19+19+17=5519 + 19 + 17 = 55 friends in total.

In the fourth testcase, Monocarp can choose day 11 for skiing, day 44 for a movie and day 99 for board games. 17+19+20=5617 + 19 + 20 = 56 friends in total.

在第一个测试用例中,Monocarp 可以选择第 22 天滑雪、第 11 天看电影、第 33 天玩桌游。这样,将有 a2=10a_2 = 10 位朋友和他一起滑雪,b1=10b_1 = 10 位朋友和他一起看电影,c3=10c_3 = 10 位朋友和他一起玩桌游。朋友总数为 3030。

在第二个测试用例中,Monocarp 可以选择第 11 天滑雪、第 44 天看电影、第 22 天玩桌游,总计 30+20+25=7530 + 20 + 25 = 75 位朋友。注意:Monocarp 不能在同一天安排多项活动,因此他不能将所有活动都安排在第 11 天。

在第三个测试用例中,Monocarp 可以选择第 22 天滑雪、第 33 天看电影、第 77 天玩桌游,总计 19+19+17=5519 + 19 + 17 = 55 位朋友。

在第四个测试用例中,Monocarp 可以选择第 11 天滑雪、第 44 天看电影、第 99 天玩桌游,总计 17+19+20=5617 + 19 + 20 = 56 位朋友。

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

首页