B - Palace


Time limit : 2sec / Memory limit : 1024MB

Score: 200 points

Problem Statement

A country decides to build a palace.

In this country, the average temperature of a point at an elevation of x meters is Tx×0.006 degrees Celsius.

There are N places proposed for the place. The elevation of Place i is Hi meters.

Among them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.

Print the index of the place where the palace should be built.

It is guaranteed that the solution is unique.

Constraints

  • 1≤N≤1000
  • 0≤T≤50
  • −60≤AT
  • 0≤Hi≤105
  • All values in input are integers.
  • The solution is unique.

Input

Input is given from Standard Input in the following format:

N
T A
H1 H2 HN

Output

Print the index of the place where the palace should be built.


Sample Input 1

Copy
2
12 5
1000 2000

Sample Output 1

Copy
1
  • The average temperature of Place 1 is 12−1000×0.006=6 degrees Celsius.
  • The average temperature of Place 2 is 12−2000×0.006=0 degrees Celsius.

Thus, the palace should be built at Place 1.

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
//#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF (1<<31)-1;
#define mem(a) (memset(a,0,sizeof(a)))
int main()
{
double MAX = INF;
int N,T,A;
int pre;
int deg;
double result;
cin>>N;
cin>>T>>A;
for(int i=;i<=N;i++){
cin>>deg;
result = abs(A - (T-deg*0.006));
if(result < MAX){
MAX = result;
pre = i;
//cout<<MAX<<endl;
}
}
cout<<pre<<endl;
return ;
}

最新文章

  1. css3 三角形
  2. Asp.net Core WebApi 返回JSON自动驼峰格式化问题
  3. JavaWeb学习之Servlet(三)----Servlet的映射匹配问题、线程安全问题
  4. sql点滴39—解决数据库日志文件过大的问题
  5. 获取Map API Key
  6. 开心菜鸟系列学习笔记------------javascript(6)
  7. 【Android开发经验】使用反射,得到的类的字段、方法、并实现了简单的调用
  8. jiayuan
  9. g.DrawImage图片合成在本机可以,在服务器一直报内存不够
  10. 运维seq语法
  11. CentOS_6.5配置iptables防火墙策略
  12. leetcode39
  13. Unity Chan 2D Asset
  14. Cython的简单使用
  15. pytest十:用例 a 失败,跳过测试用例 b 和 c 并标记失败 xfail
  16. Oracle 11.2.0.4.0 Dataguard部署和日常维护(2)-Datauard部署篇
  17. tornado url配置
  18. IPC_Binder_java_2
  19. MDI QMdiArea 多文档区域
  20. MyEclipse优化,解决MyEclipse运行慢、卡顿问题

热门文章

  1. Docker学习笔记_初装的Centos无ifconfig
  2. Linux文件系统操作命令
  3. Django----配置数据库读写分离
  4. 【Azure Active Directory】单一登录 (SAML 协议)
  5. DropDownList1.Items.Insert 与 DropDownList1.Items.Add 的区别
  6. spring深入了解心得
  7. C#三层架构搭建
  8. angular formBuilder
  9. VSCode调试设置
  10. stream.fail() eof() EOF