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 ;
}

AtCoder Beginner Contest 113 B的更多相关文章

  1. AtCoder Beginner Contest 113 C

    C - ID Time limit : 2sec / Memory limit : 1024MB Score: 300 points Problem Statement In Republic of ...

  2. AtCoder Beginner Contest 113 D Number of Amidakuji

    Number of Amidakuji 思路:dp dp[i][j]表示经过(i, j) 这个点的方案数 然后一层一层地转移, 对于某一层, 用二进制枚举这一层的连接情况, 判断连接是否符合题意, 然 ...

  3. AtCoder Beginner Contest 113 A

    A - Discount Fare Time limit : 2sec / Memory limit : 1024MB Score: 100 points Problem Statement Ther ...

  4. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  5. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  6. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  7. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  8. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  9. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

随机推荐

  1. SpringBoot22 Ajax跨域、SpringBoot返回JSONP、CSRF、CORS

    1 扫盲知识 1.1 Ajax为什么存在跨域问题 因为浏览器处于安全性的考虑不允许JS执行跨域请求. 1.2 浏览器为什么要限制JS的跨域访问 如果浏览器允许JS的跨域请求就很容易造成 CSRF (C ...

  2. Lambda01 编程范式、lambda表达式与匿名内部类、函数式接口、lambda表达式的写法

    1 编程范式 主要的编程范式有三种:命令式编程,声明式编程和函数式编程. 1.1 命令式编程 关注计算机执行的步骤,就是告诉计算机先做什么后做什么 1.2 声明式编程 表达程序的执行逻辑,就是告诉计算 ...

  3. Win10 Tensorflow 配置Mask_RCNN

    1.安装Anaconda3 下载地址  Anaconda 官网下载地址:https://www.continuum.io/downloads 下载以后,点击exe程序,开始安装,详细的安装过程(图片参 ...

  4. mongo状态查看方法

    列举一些常用的mongodb状态查看方法. 1.mongostat 是mongdb自带的状态检测工具, inserts/s 每秒插入次数 query/s 每秒查询次数 update/s 每秒更新次数 ...

  5. linux的deamon后台运行

    有的时候需要将程序一直跑在后台,比如一些服务类代码,或者一些监控类代码.使用deamon是正确的一种思路. 以前我们在看<unix环境高级编程>的时候,有专门的整章详细介绍如何编写一个后台 ...

  6. linux安装JDK后发现系统带有openjdk的处理

    1.JDK下载. 官网下载网址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ...

  7. 【linux命令】setterm控制终端属性命令(中英文)

    [linux命令]setterm控制终端属性命令(中英文) 2018年03月23日 17:13:44 阅读数:489 标签: linux 更多 个人分类: linux 摘自:https://blog. ...

  8. Android Activity的切换动画(overridePendingTransition)

    overridePendingTransition 1.平时Activity的切换是就是从中间弹出来,然后遮盖住之前的Activity.这种效果看到很多后就想给他换成其他的效果,如: 要显示的Acit ...

  9. 前端框架 json 返回值

    layui: string strJson = "{\"code\": \"0\",\"msg\": \"\" ...

  10. @html.dropdown用法

    controller1 List<SelectListItem> itemList = new List<SelectListItem>() { "}, " ...