发布网友 发布时间:2022-05-13 02:42
共2个回答
懂视网 时间:2022-05-13 07:04
codeforces.com/contest/421/problem/Dconst int MAXN = 310000;struct Node{ int n, num; int operator< (const Node& a) const { return num < a.num; }} ipt[MAXN];int cnt[MAXN];int cmp(Node& a, int b){ return a.num < b;}int main(){// freopen("in.txt", "r", stdin); int n, k, a, b; while (~RII(n, k)) { CLR(cnt, 0); map, int> mp; FE(i, 1, n) ipt[i].n = i; FE(i, 1, n) ipt[i].num = 0; REP(i, n) { RI(a); ipt[a].num++; cnt[a]++; RI(b); ipt[b].num++; cnt[b]++; if (a > b) swap(a, b); mp[MP(a, b)]++; } sort(ipt + 1, ipt + n + 1); LL ans = 0; FE(i, 1, n) { int ind = lower_bound(ipt + i + 1, ipt + n + 1, k - ipt[i].num, cmp) - ipt; ans += n - ind + 1; } FC(it, mp) { a = (it->first).first; b = (it->first).second; if (cnt[a] + cnt[b] >= k && cnt[a] + cnt[b] - it->second < k) ans--; } cout << ans << endl; } return 0;}
热心网友 时间:2022-05-13 04:12
财富值无所谓,只要能帮你的忙。