CodeforcesRound#261(Div.2)D.PashmakandParmida&#3
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CodeforcesRound#261(Div.2)D.PashmakandParmida&#3,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2124字,纯文字阅读大概需要4分钟。
内容图文
![CodeforcesRound#261(Div.2)D.PashmakandParmida](/upload/InfoBanner/zyjiaocheng/534/3c9714b85b0c45aea9fff77ee16e12fc.jpg)
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 con
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 denotef(l,?r,?x) the number of indicesk such that: l?≤?k?≤?r andak?=?x. His task is to calculate the number of pairs of indiciesi,?j (1?≤?i?j?≤?n) such thatf(1,?i,?ai)?>?f(j,?n,?aj).
Help Pashmak with the test.
Input
The first line of the input contains an integer n(1?≤?n?≤?106). The second line containsn space-separated integers a1,?a2,?...,?an(1?≤?ai?≤?109).
Output
Print a single integer — the answer to the problem.
Sample test(s)
Input
7 1 2 1 1 2 2 1
Output
8
Input
3 1 1 1
Output
1
Input
5 1 2 3 4 5
Output
0
由于原数过大,可使用map 映射,就不需要离散化了~两个数组,一个记录前面与本数相等的数的个数,一个记录后面与本数相等的数的个数~
题目便转化成求逆序数对,树状数组。答案long long
CODE:
#include#include #include #include #include #include #include #include #include #include #include
内容总结
以上是互联网集市为您收集整理的CodeforcesRound#261(Div.2)D.PashmakandParmida&#3全部内容,希望文章能够帮你解决CodeforcesRound#261(Div.2)D.PashmakandParmida&#3所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。