796A - Buying A House

本文介绍了一个算法,该算法通过输入一系列价格数据,在给定条件下找到离目标位置最近的有效价格的距离。程序使用C++编写,通过双向搜索的方式找到符合条件的价格点,并计算其与指定位置之间的距离。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;

int main(){
	int n, m, k;
	while (cin >> n >> m >> k){
		vector<int> prices(n + 1);
		for (int i = 1; i <= n; i++) cin >> prices[i];
		int i = m - 1;
		int j = m + 1;
		int distance = 0;
		while (i >= 1 || j <= n){
			if (i >= 1){
				if (prices[i] <= k&&prices[i] != 0){
					distance = (m - i) * 10;
					break;
				}
			}
			if (j <= n){
				if (prices[j] <= k&&prices[j] != 0){
					distance = (j - m) * 10;
					break;
				}
			}
			i--;
			j++;
		}
		cout << distance << endl;
	}
	return 0;
}

帮我看看这段话有没有语法错误:The first effect of guaranteeing people have basic financial products and services is increasing the overall quality of people’s lives. Ensuring reliable access to financial products and services can contribute to helping families and companies plan the future from two aspects, long-term goals and unexpected emergencies (The World Bank, 2022). Long-term goals mean long-term investments such as investments in health: saving money against illness, saving for a child’s education, saving for a house or car, etc. Unexpected emergencies mean managing risk, that is, people can apply for a loan from the bank when they are in the face of a sudden bankruptcy or business shock. Furthermore, when people meet weather financial shocks, the government and banks will give some financial assistance. With these financial services, people have a basic guarantee of life and a clear plan for the future in the meanwhile. Guarantee of financial services leads them to save a sum of money in a safe bank account for buying a house, providing funds for children’s education, and buying medical insurance for both themselves and their families to prevent the sudden arrival of diseases. In daily life, online payment improves life efficiency such as reducing queuing time. Additionally, in occupational life, financial guarantees can encourage and empower young people can be bolder to pursue their entrepreneurial dreams by providing them with start-up funds from banks. All in all, the guarantee of financial products leads to individuals plan for their financial futures and improve their overall quality of life.
05-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值