CF961E Tufurama
Posted AntiQuality
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF961E Tufurama相关的知识,希望对你有一定的参考价值。
挺巧妙的数据结构题(不过据说这是一种套路?
E. Tufurama
TV series have n seasons (numbered 1 through n), the i-th season has ai episodes (numbered 1 through ai). Polycarp thinks that if for some pair of integers x and y (x < y) exist both season x episode y and season y episode x then one of these search queries will include the wrong results. Help Polycarp to calculate the number of such pairs!
The first line contains one integer n (1 ≤ n ≤ 2·10^5) — the number of seasons.
The second line contains n integers separated by space a1, a2, ..., an (1 ≤ ai ≤ 10^9) — number of episodes in each season.
Print one integer — the number of pairs x and y (x < y) such that there exist both season x episode y and season y episode x.
题目大意
有一部电视剧有n季,每一季有ai集。定义二元组(i,j):存在第i季有第j集。求(i,j)与(j,i)同时合法(i<j)的对数。
看上去很可做的样子,对吧……
题目分析
基础的暴力
从1..n季,每一季都分别判断对答案的贡献。
例如对于 4 3 5 1 2 就
以上是关于CF961E Tufurama的主要内容,如果未能解决你的问题,请参考以下文章