CF459D.Pashmak and Parmida's problem
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that consists of n integers a1,a2,...,an . Let's denote f(l,r,x) the number of indices k such that: l<=k<=r and ak=x . His task is to calculate the number of pairs of indicies i,j (1<=i<j<=n) such that f(1,i,a_{i})>f(j,n,a_{j}) .
Help Pashmak with the test.
帕米达是个聪明的女孩,今年她想参加奥林匹克竞赛。当然,她希望她的搭档也很聪明(虽然他并不聪明)!帕尔米达为帕什马克准备了以下测试题。
有一个序列 a 由 n 个整数a1,a2,...,an组成。让我们用 f(l,r,x) 表示这样的索引 k 的个数: l<=k<=r 和 ak=x 。他的任务是计算 i, j 和 i,j (1<=i<j<=n)这两个索引的对数。 (1<=i<j<=n) 中 f(1,i,ai)>f(j,n,aj) 的个数。
帮助 Pashmak 完成测试。
输入格式
The first line of the input contains an integer n (1<=n<=106) . The second line contains n space-separated integers a1,a2,...,an (1<=ai<=109) .
输入
输入的第一行包含一个整数 n (1<=n<=106) .第二行包含 n 个空格分隔的整数 a1,a2,...,an (1<=ai<=109)
输出格式
Print a single integer — the answer to the problem.
输出
打印一个整数--问题的答案。
输入输出样例
输入#1
7 1 2 1 1 2 2 1
输出#1
8
输入#2
3 1 1 1
输出#2
1
输入#3
5 1 2 3 4 5
输出#3
0