CF61E.Enemy is weak

普及/提高-

通过率:0%

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,ki,j,k such that i<j<k and a_{i}>a_{j}>a_{k} where axa_{x} is the power of man standing at position xx . 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 < k 和 ai > aj > ak 的三联数 i, j, k ,其中 ax 是站在 x 位置上的人的力量。罗马军队有一个特点--军队中所有人的力量都是不同的。

帮助沙普尔找出罗马人的弱点。

输入格式

The first line of input contains a single number nn ( 3<=n<=1063<=n<=10^{6} ) — the number of men in Roman army. Next line contains nn different positive integers aia_{i} ( 1<=i<=n,1<=ai<=1091<=i<=n,1<=a_{i}<=10^{9} ) — powers of men in the Roman army.
输入
第一行包含一个数字 nn ( 3<=n<=1063<=n<=10^{6} ) - 罗马军队的人数。下一行包含 n 不同的正整数 aia_{i} ( 1<=i<=n,1<=ai<=1091<=i<=n,1<=a_{i}<=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).
输出
一个整数,即罗马军队的弱点。
请不要使用 %lld specificator 在 C++ 中读写 64 位整数。最好使用 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
    
首页