海洋之心


私信TA

用户名:wanggongsheng

访问量:122755

签 名:

等  级
排  名 17
经  验 20542
参赛次数 3
文章发表 163
年  龄 26
在职情况 学生
学  校
专  业 计算机技术

  自我简介:

读研ing,平时不登录dotcpp

解题思路:

注意事项:

参考代码:

#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100000+10;
typedef struct node{
	int c;
	int L,R;	
}Node;
Node A[110];
int main(void)
{
	int n,m,x;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int L,R,c;
		cin>>L>>R>>c;
		A[i].c=c;
		A[i].L=L;
		A[i].R=R;
	} 
	cin>>x;
	int max=-1;
	for(int i=1;i<=m;i++)
	{
		if((A[i].R-x)*(A[i].L-x)<=0)
		{
			max=i;
		}
	}
	if(max==-1) cout<<0;
	else cout<<A[max].c;
	return 0;
}


 

0.0分

9 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区