高跟鞋

来源:互联网 发布:虚拟主机源码 编辑:程序博客网 时间:2024/04/27 20:06
Problem Description
身高A的DW喜欢穿高跟鞋,而且是越高越好。可惜他男朋友只有B高,为了照顾下他的感受,DW出门的时候只能挑穿上之后不会比他高的鞋子。今天DW又要出门啦,请替她从N双鞋子里面挑一双吧。
Input
有多组数据,每组两行。
第一行输入三个正整数N,A,B(A<B)。
第二行输入N个正整数,代表鞋子的高度
Output
输出挑出来的鞋子的高度
Sample Input
15 167 177
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Sample Output

10

#include<stdio.h>#include<iostream>#include<string.h>#include<algorithm>using namespace std;int shoes[1005],n,height_a,height_b;int main(){//freopen("b.txt","r",stdin);int i;while(scanf("%d",&n)==1){scanf("%d %d",&height_a,&height_b);for(i=1;i<=n;i++){scanf("%d",&shoes[i]);}sort(shoes+1,shoes+n+1);for(i=1;i<=n;i++)//用循环来找一双最大的满足条件的鞋if(height_a+shoes[i]>height_b) break;printf("%d\n",shoes[i-1]);}return 0;}


0 0