ssl提高组周六模拟赛【2018.9.23】

版权声明:原创,未经作者允许禁止转载 https://blog.csdn.net/Mr_wuyongcong/article/details/82855870

前言

我ssl模拟式爆炸了,我已经打算从1楼跳下去了


成绩

因为比赛的时候数据出bug,所以排名有些奇怪,就不放了。


正题


T 1 : n s s l 1162 T1:nssl1162- 农夫约的假期【中位数 , , 贪心】

博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82822005


T 2 : n s s l 1163 T2:nssl1163- x x 游世界树【树形 d p , dp, 二次扫描和换根法】

博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82822084


n s s l 1164 nssl1164- 观察【平衡树 , L C A ,LCA

博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82855481


s o m e   o f   c o d e some\ of\ code


T1 50分code

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,z,x[100001],y[100001],p,sum_x,sum_y,ans;
int main()
{
	scanf("%d%d%d",&n,&m,&z);
	for(int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&p),ans+=p;
	sort(x+1,x+1+m);
	sort(y+1,y+1+m);
	int xn=(m+1)/2,yn=(m+1)/2;
	for(int i=1;i<=m;i++)
	  ans+=(abs(x[xn]-x[i])+abs(y[yn]-y[i]))*z;
	printf("%d\n%d %d",ans,x[xn],y[yn]);
}

尾声

没了

猜你喜欢

转载自blog.csdn.net/Mr_wuyongcong/article/details/82855870