CF-395A1 Skis (two pointer)


先对无序序列排序,一个正方向移动,一个从逆方向移动。时间复杂度竟为O(n)。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std ;
int a[1000005];
int main()
{
	int n,q,l,r,ans;	
    while(scanf("%d %d",&n,&q)!=EOF){
		for(int i=0;i<n;i++) scanf("%d",&a[i]);
		sort(a,a+n);
		l=0,r=n-1;
		ans=0;
		while(l<r){
			while(a[l]+a[r]>q&&r>l) r--;
			if(a[l]+a[r]==q&&(l!=r)){
				r--;
				ans++;
			}
			l++;
		}
		printf("%d\n",ans);
    }
 	return 0 ;
}

好的,根据您的要求,我生成了一个包含100行数据的Excel数据集,用于训练、预测和评估每个类别物体危险系数模型。每行数据的特征包括物体类别、物体像素深度信息、物体像素面积大小、物体危险系数。 以下是数据集的前10行示例: | 物体类别 | 物体像素深度信息 | 物体像素面积大小 | 物体危险系数 | | -------- | ---------------- | ---------------- | ------------ | | person | 156 | 2346 | 0.8 | | bicycle | 98 | 918 | 0.2 | | car | 215 | 5430 | 0.6 | | motorcycle | 181 | 1123 | 0.4 | | airplane | 68 | 7653 | 0.3 | | bus | 123 | 6543 | 0.5 | | train | 198 | 8765 | 0.7 | | truck | 177 | 5432 | 0.8 | | boat | 87 | 2345 | 0.2 | | traffic light | 201 | 432 | 0.1 | 物体类别包括['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']。 感谢您的提问,有什么其他的问题我可以帮您解答吗?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值