李超线段树—板子

#include<bits/stdc++.h>
#define lc x<<1,l,mid
#define rc x<<1|1,mid+1,r
using namespace std;
const double eps=1e-12;
const int N=50010;

struct Line
{
	double k,b;
	int l,r;
	int flag;
}tr[N*4];

double calc(Line line,int x)
{
	return line.k*x+line.b;
}
int cross(Line l1,Line l2)
{
	return floor((l1.b-l2.b)/(l2.k-l1.k));
}

void build(int x,int l,int r)
{
	tr[x]=(Line){0, 0, 1, 50000, false};//?
	if(l==r) return ;
	int mid=l+r>>1;
	build(lc);
	build(rc);
}
void modify(int x,int l,int r,Line k)
{
	if(k.l<=l && r<=k.r)
	{
		if(!tr[x].flag)
		{
			tr[x]=k;
			tr[x].flag=true;
		}
		else if(calc(k,l)-calc(tr[x],l)>eps && calc(k,r)-calc(tr[x],r)>eps)
		{
			tr[x]=k;
		}
		else if(calc(k,l)-calc(tr[x],l)>eps || calc(k,r)-calc(tr[x],r)>eps)
		{
			int mid=l+r>>1;
			if(calc(k,mid)-calc(tr[x],mid)>eps) swap(k,tr[x]);
			if(cross(k,tr[x])<=mid) modify(lc,k);
			else modify(rc,k);
		}
	}
	else
	{
		int mid=l+r>>1;
		if(k.l<=mid) modify(lc,k);
		if(mid<k.r) modify(rc,k);
//		if(mid<=k.r) modify(lc,k);
//		if(k.l<mid) modify(rc,k);
	}
}

double query(int x,int l,int r,int pos)
{
	if(l==r) return calc(tr[x],pos);//?
	int mid=l+r>>1;
	double ans=calc(tr[x],pos);
	if(pos<=mid) return max(ans,query(lc,pos));
	else return max(ans,query(rc,pos));
}


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	int n;cin>>n;
	const int root=1;
//	build(root, 1, 50000);
	for(int i=1;i<=n;i++)
	{
		string opt;cin>>opt;
		if(opt[0]=='P')
		{
			Line now;
			cin>>now.b>>now.k;
			now.b=now.b-now.k;
			now.l=1;now.r=50000;
			modify(root, 1, 50000, now);
		}
		else
		{
			int day;
			cin>>day;
			double ans=query(root, 1, 50000, day);
			cout<<floor(ans/100)<<endl;
		}
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用和提到,Linux下安装ffmpeg是非常方便的。下面给出在Linux上安装ffmpeg的步骤: 1. 首先,需要安装Cygwin。Cygwin是一个在Windows上运行类似于Linux的环境的工具。可以从官方网站上下载并安装。 2. 安装完Cygwin后,打开终端,输入以下命令下载x264源代码并进行编译: ``` wget http://mirror.yandex.ru/mirrors/ftp.videolan.org/x264/snapshots/last_x264.tar.bz2 bunzip2 last_x264.tar.bz2 tar -vxf last_x264.tar cd last_x264 ./configure --enable-static --enable-shared --disable-asm --disable-avs make && sudo make install ``` 3. 然后,从ffmpeg官网下载ffmpeg源代码,并进行编译。编译方法可以参考官方文档或者在终端中输入以下命令: ``` wget http://ffmpeg.org/releases/ffmpeg-[版本号].tar.gz tar -xzvf ffmpeg-[版本号].tar.gz cd ffmpeg-[版本号] ./configure --enable-shared make sudo make install ``` 其中,是你想要安装的ffmpeg的版本号。 4. 编译完成后,就可以使用ffmpeg了。可以通过在终端中输入`ffmpeg`命令来验证是否安装成功。 请注意,以上步骤仅适用于在Linux系统上安装ffmpeg。如果你是在其他操作系统上进行安装,请参考相关的文档或者教程。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Windows下编译安装 FFmpeg](https://blog.csdn.net/heng615975867/article/details/119821945)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值