Codeforces Round #408 (Div. 2) A.Buying A House【模拟】水题~

在这个问题中,我们需要帮助一位名叫Zane的巫师找到离他心仪女孩最近且价格合适的房子。通过给定的房子价格列表和Zane的预算,我们要找出最短的距离。

A. Buying A House
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.

The girl lives in house m of a village. There are n houses in that village, lining in a straight line from left to right: house 1, house 2, ..., house n. The village is also well-structured: house i and house i + 1 (1 ≤ i < n) are exactly 10 meters away. In this village, some houses are occupied, and some are not. Indeed, unoccupied houses can be purchased.

You will be given n integers a1, a2, ..., an that denote the availability and the prices of the houses. If house i is occupied, and therefore cannot be bought, then ai equals 0. Otherwise, house i can be bought, and ai represents the money required to buy it, in dollars.

As Zane has only k dollars to spare, it becomes a challenge for him to choose the house to purchase, so that he could live as near as possible to his crush. Help Zane determine the minimum distance from his crush's house to some house he can afford, to help him succeed in his love.

Input

The first line contains three integers n, m, and k (2 ≤ n ≤ 100, 1 ≤ m ≤ n, 1 ≤ k ≤ 100) — the number of houses in the village, the house where the girl lives, and the amount of money Zane has (in dollars), respectively.

The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 100) — denoting the availability and the prices of the houses.

It is guaranteed that am = 0 and that it is possible to purchase some house with no more than k dollars.

Output

Print one integer — the minimum distance, in meters, from the house where the girl Zane likes lives to the house Zane can buy.

Examples
Input
5 1 20
0 27 32 21 19
Output
40
Input
7 3 50
62 0 0 0 99 33 22
Output
30
Input
10 5 100
1 0 1 0 0 0 0 0 1 1
Output
20
Note

In the first sample, with k = 20 dollars, Zane can buy only house 5. The distance from house m = 1 to house 5 is 10 + 10 + 10 + 10 = 40 meters.

In the second sample, Zane can buy houses 6 and 7. It is better to buy house 6 than house 7, since house m = 3 and house 6 are only 30 meters away, while house m = 3 and house 7 are 40 meters away.


题目大意:

给你N个房子,每个房子的价格为a【i】.a【i】==0的表示不能购买,现在他的位子在m,有k钱.他想买一个房子,使得这个房子尽可能的靠近m这个位子。

现在设定两个房子间的距离为10.


思路:


直接暴力模拟即可。


Ac代码:

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int a[150];
int main()
{
    int n,m,k;
    while(~scanf("%d%d%d",&n,&m,&k))
    {
        int output=0x3f3f3f3f;
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        for(int i=m;i<=n;i++)
        {
            if(a[i]!=0)
            {
                if(a[i]<=k)output=min(output,(i-m)*10);
            }
        }
        for(int i=m;i>=1;i--)
        {
            if(a[i]!=0)
            {
                if(a[i]<=k)output=min(output,(m-i)*10);
            }
        }
        printf("%d\n",output);
    }
}







内容概要:本文围绕“考虑隐私保护的分布式联邦学习电力负荷预测研究”展开,提出了一种融合联邦学习框架与隐私保护机制的电力负荷预测方法,旨在解决传统集中式数据处理中潜在的用户隐私泄露问。通过构建分布式模型训练体系,各参与方在本地完成模型训练,仅向中心服务器上传模型参数或梯度信息,实现“数据不动模型动”的协同建模模式,确保数据“可用不可见”。研究采用Python语言实现了完整的联邦学习流程,涵盖客户端本地训练、全局模型聚合、隐私保护策略(如差分隐私或同态加密)集成、通信机制设计及预测性能评估等核心模块,显著提升了电力负荷预测在隐私安全与模型精度之间的平衡能力。; 适合人群:具备Python编程基础和机器学习基础知识,从事电力系统、智能电网、能源大数据分析、数据隐私保护等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于居民或工业级电力负荷预测任务,在保障用户用电数据隐私的前提下实现高精度预测;②为构建符合数据合规要求的智慧能源管理系统提供技术支撑;③推动联邦学习在能源互联网、跨企业数据协作等场景中的落地应用,促进多方协同建模与数据价值释放。; 阅读建议:建议读者结合文中提供的Python代码进行实践操作,重点关注联邦学习的通信轮次设置、本地训练迭代策略、模型聚合算法设计以及隐私噪声添加机制的实现细节,并可根据实际需求替换底层预测模型(如LSTM、XGBoost、Transformer等)以进一步优化预测性能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值