2019 Multi-University Training Contest 6
Posted accpted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019 Multi-University Training Contest 6相关的知识,希望对你有一定的参考价值。
Salty Fish
Support or Not
Three Investigators
Milk Candy
Ridiculous Netizens
Stay Real
#include <bits/stdc++.h> using namespace std; const int maxn=100010; typedef long long ll; struct node ll val,id; node(int _val,int _id):val(_val),id(_id) ; bool operator < (const node &b)const return val<b.val; ; ll h[maxn],vis[maxn*2],n,suma,sumb,flag,fa; priority_queue<node>q; int main() int T; scanf("%d",&T); while (T--) scanf("%lld",&n); for (int i=1; i<=n; i++) vis[i]=1; for (int i=1; i<=n; i++) scanf("%lld",&h[i]); if (vis[i<<1]==0&&vis[i<<1|1]==0) q.push(node(h[i],i)); suma=sumb=0; flag=1; while (!q.empty()) node tmp=q.top(); q.pop(); if (flag) suma+=tmp.val; else sumb+=tmp.val; vis[tmp.id]=0; flag^=1; fa=tmp.id>>1; if (vis[fa<<1]==0&&vis[fa<<1|1]==0&&fa!=0) q.push(node(h[fa],fa)); printf("%lld %lld\n",suma,sumb); return 0;TDL
Snowy Smile
Faraway
Nonsense Time
Speed Dog
11 Dimensions
以上是关于2019 Multi-University Training Contest 6的主要内容,如果未能解决你的问题,请参考以下文章
2019 Multi-University Training Contest 6
2019 Multi-University Training Contest 6
2019 Multi-University Training Contest 6
2019 Multi-University Training Contest 3