链接:https://ac.nowcoder.com/acm/contest/13168/C
来源:牛客网
示例1
输入
复制
5 3
1 100 200
2 100 99
3 100 50
3 100 50
2 100 98
输出
复制
B 100 49
A 1 197
A 49 100
0.1965897693
示例2
输入
复制
4 4
3 100 99
2 100 99
1 100 99
4 100 99
输出
复制
A 0 99
A 0 99
A 0 99
A 0 99
0.4974874372
示例3
输入
复制
4 4
4 99 100
1 100 99
3 100 99
2 99 100
输出
复制
A 0 99
B 99 0
A 0 99
B 99 0
0.0000000000
理解题意后照着做就行了
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
ll x=0,y=0;
}v[11000];
int n,m,t;
ll tx,ty,ttx,tty;
double x=0,y=0;
int main()
{
ios::sync_with_stdio(false);
cin>>n>>m;
while(n--)
{
cin>>t>>tx>>ty;
y+=tx+ty;
v[t].x+=tx;v[t].y+=ty;
}
for(int i=1;i<=m;i++)
{
if(v[i].x>v[i].y)
{
ttx=v[i].x-(v[i].x+v[i].y)/2-1;
tty=v[i].y;
x+=ttx-tty;
cout<<'A'<<" ";
cout<<ttx<<" "<<tty;
}
else if(v[i].x<v[i].y)
{
ttx=v[i].x;
tty=v[i].y-(v[i].x+v[i].y)/2-1;
x+=ttx-tty;
cout<<'B'<<" ";
cout<<ttx<<" "<<tty;
}
cout<<endl;
}
if(x<0) x*=-1;
cout<<fixed<<setprecision(10)<<x/y;
return 0;
}