QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB

#23951. 铜锣烧

Estadísticas

题目描述

JOI 君打算制作铜锣烧。

一个铜锣烧由豆沙馅与饼皮各 $1$ 个制作而成,所有豆沙馅与饼皮都定义了用正整数表示的“美味度”。有从 $1$ 到 $N$ 编号的 $N$ 种豆沙馅,豆沙馅 $i$($1 \le i \le N$)的美味度为 $A_i$。此外,还有从 $1$ 到 $M$ 编号的 $M$ 种饼皮,饼皮 $j$($1 \le j \le M$)的美味度为 $B_j$。

JOI 君会尝试这些豆沙馅与饼皮的所有组合,制作出 $N \times M$ 个铜锣烧。每个铜锣烧的美味度等于豆沙馅与饼皮的美味度之和乘以豆沙馅与饼皮的美味度中的较大值。

求这 $N \times M$ 个铜锣烧的美味度总和。

约束条件

  • $1 \le N \le 100$。
  • $1 \le M \le 100$。
  • $1 \le A_i \le 100$($1 \le i \le N$)。
  • $1 \le B_j \le 100$($1 \le j \le M$)。
  • 输入的值均为整数。

输入

输入以如下格式给出:
$N$ $M$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_M$

输出

输出 $N \times M$ 个铜锣烧的美味度总和。

请不要输出除答案以外的任何内容。(请不要输出提示输入的文字等。)

关于解答格式,也可以参考练习题及其解答样例。


样例输入 1

2 2
1 2
2 5

样例输出 1

79

对于制作出的 $4$ 个铜锣烧,各自的美味度如下:

  • 由豆沙馅 $1$ 和饼皮 $1$ 制作出的铜锣烧的美味度为:豆沙馅与饼皮的美味度之和 $3 (= 1 + 2)$ 乘以两者美味度中的较大值 $2$,结果为 $6$。
  • 由豆沙馅 $1$ 和饼皮 $2$ 制作出的铜锣烧的美味度为:豆沙馅与饼皮的美味度之和 $6 (= 1 + 5)$ 乘以两者美味度中的较大值 $5$,结果为 $30$。
  • 由豆沙馅 $2$ 和饼皮 $1$ 制作出的铜锣烧的美味度为:豆沙馅与饼皮的美味度之和 $4 (= 2 + 2)$ 乘以两者美味度中的较大值 $2$,结果为 $8$。
  • 由豆沙馅 $2$ 和饼皮 $2$ 制作出的铜锣烧的美味度为:豆沙馅与饼皮的美味度之和 $7 (= 2 + 5)$ 乘以两者美味度中的较大值 $5$,结果为 $35$。

根据它们的总和,输出 $79 (= 6 + 30 + 8 + 35)$ 即可。


样例输入 2

1 5
50
9 7 5 4 1

样例输出 2

13800

样例输入 3

15 5
5 10 52 31 14 16 19 1 9 20 80 19 11 34 72
20 2 4 9 19

样例输出 3

116756

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.