Codeforces Round #575 (Div. 3)
A
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL fff(LL a,LL b,LL c)
{
LL ans1=max(a,b);
LL ans2=min(a,b);
LL ans3=c-(ans1-ans2);
if(ans3<=0) return ans2+c;
else return ans1+ans3/2;
}
int main()
{
int q;
scanf("%d",&q);
while(q--){
LL a,b,c;
scanf("%lld %lld %lld",&a,&b,&c);
LL ans=0;
ans=max(ans,fff(a,b,c));
ans=max(ans,fff(a,c,b));
ans=max(ans,fff(b,a,c));
ans=max(ans,fff(b,c,a));
ans=max(ans,fff(c,b,a));
ans=max(ans,fff(c,a,b));
cout<<ans<<endl;
}
return 0;
}
B
# include <bits/stdc++.h>
using namespace std;
int main()
{
int q;
scanf("%d",&q);
while(q--){
queue<int> a;
queue<int> b;
int ans;
int n,k;
scanf("%d %d",&n,&k);
for(int i=1;i<=n;i++){
scanf("%d",&ans);
if(ans%2==1)a.push(i);
}
if(a.size()<k){
printf("NO\n");
}else if(a.size()==k){
printf("YES\n");
while(!a.empty()&&a.size()>1){
cout<<a.front()<<" ";
a.pop();
}
printf("%d\n",n);
}else{
for(int i=1;i<k;i++){
b.push(a.front());
a.pop();
}
if(a.size()%2==0){
printf("NO\n");
}else{
printf("YES\n");
while(!