国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Educational Codeforces Round 3 B

2019-11-06 06:37:19
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

B. The Best Gift time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Emily’s birthday is next week and Jack has decided to buy a PResent for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.

In the bookshop, Jack decides to buy two books of different genres.

Based on the genre of books on sale in the shop, find the number of options available to Jack for choosing two books of different genres for Emily. Options are considered different if they differ in at least one book.

The books are given by indices of their genres. The genres are numbered from 1 to m.

Input The first line contains two positive integers n and m (2?≤?n?≤?2·105,?2?≤?m?≤?10) — the number of books in the bookstore and the number of genres.

The second line contains a sequence a1,?a2,?…,?an, where ai (1?≤?ai?≤?m) equals the genre of the i-th book.

It is guaranteed that for each genre there is at least one book of that genre.

Output Print the only integer — the number of ways in which Jack can choose books.

It is guaranteed that the answer doesn’t exceed the value 2·109.

Examples input 4 3 2 1 3 1 output 5 input 7 4 4 2 3 1 2 4 3 output 18 Note The answer to the first test sample equals 5 as Sasha can choose:

the first and second books, the first and third books, the first and fourth books, the second and third books, the third and fourth books.

#include <stdio.h>using namespace std;const int N=2e5+10;int a[N];int bj[15];int foo[N];int main() { int n,m; scanf("%d%d",&n,&m); for(int i=1; i<=n; i++) { scanf("%d",&a[i]); if(!bj[a[i]]) { bj[a[i]]=1; } else { foo[a[i]]++; } } long long sum=0; for(int i=1;i<=n;i++){ sum+=(n-i-foo[a[i]]); foo[a[i]]--; } printf("%I64d/n",sum); return 0;}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 花莲市| 当涂县| 新津县| 北京市| 华蓥市| 定结县| 广河县| 来凤县| 阳朔县| 五指山市| 金华市| 加查县| 晋宁县| 安多县| 乌海市| 定兴县| 澎湖县| 桃江县| 龙口市| 黑山县| 东乡族自治县| 南雄市| 九龙县| 吉安县| 诏安县| 山阴县| 新泰市| 任丘市| 河东区| 左云县| 利辛县| 绩溪县| 临西县| 隆子县| 从化市| 驻马店市| 柏乡县| 鄂尔多斯市| 津南区| 太仓市| 新乡县|