UVa 1428 - Ping pong

出處:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4174

解題策略:使用binary indexed tree或segment tree或稱作fenwick tree計算比d[i]小的個數

找尋相異數值的數列中任三個由小到大或由大到小數值的個數

sum(x)向左計算小於d[i]的個數

update(x)向右新增1,讓每一個右邊且大於d[i]的元素知道有d[i]存在

累加左邊小於d[i]個數乘以右邊大於d[i]個數,加上左邊大於d[i]個數乘以右邊小於d[i]個數就是答案