CF61E.Enemy is weak

普及+/提高

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".

Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.

In Shapur's opinion the weakness of an army is equal to the number of triplets i, j, k such that i < j < k and a__i > a__j > a__k where a__x is the power of man standing at position x. The Roman army has one special trait — powers of all the people in it are distinct.

Help Shapur find out how weak the Romans are.

罗马人再次发动了进攻。这一次,他们的兵力远超波斯人,但沙普尔已做好击败他们的准备。他说道:“雄狮从不畏惧百只绵羊。”

然而,沙普尔必须找出罗马军队的弱点才能将其击败。因此,他为这支军队赋予了一个“弱点值”。

在沙普尔看来,一支军队的弱点值等于满足 i<j<ki < j < k 且 ai>aj>aka_i > a_j > a_k 的三元组 (i,j,k)(i, j, k) 的个数,其中 axa_x 表示位于位置 xx 的士兵的战力。罗马军队有一个特殊性质——所有士兵的战力互不相同。

请帮助沙普尔计算出罗马军队的弱点值。

输入格式

The first line of input contains a single number n (3 ≤ n ≤ 106) — the number of men in Roman army. Next line contains n different positive integers a__i (1 ≤ i ≤ n, 1 ≤ a__i ≤ 109) — powers of men in the Roman army.

输入的第一行包含一个整数 nn(3≤n≤1063 \leq n \leq 10^6)—— 罗马军队中士兵的人数。
第二行包含 nn 个互不相同的正整数 aia_i(1≤i≤n1 \leq i \leq n,1≤ai≤1091 \leq a_i \leq 10^9)—— 罗马军队中各士兵的战斗力。

输出格式

A single integer number, the weakness of the Roman army.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

罗马军队的弱点值(一个整数)。

请注意,在 C++ 中读取或写入 64 位整数时,请勿使用 %lld 格式说明符。推荐使用 cout(您也可使用 %I64d)。

输入输出样例

  • 输入#1

    3
    3 2 1

    输出#1

    1
  • 输入#2

    3
    2 3 1

    输出#2

    0
  • 输入#3

    4
    10 8 3 1

    输出#3

    4
  • 输入#4

    4
    1 5 4 3

    输出#4

    1

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

首页