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. spring框架 使用 JdbcTemplate 对数据进行增删改查

    user=LF password=LF jdbcUrl=jdbc:oracle:thin:@localhost:1521:orcl driverClass=oracle.jdbc.driver.Ora ...

  2. 关闭是否只查看安全传送的网页内容提示框 和 是否允许运行软件,如ActiveX控件和插件提示框

    关闭是否只查看安全传送的网页内容提示框 最新编写 爬虫程序,运行程序后,电脑就总是出现下面这个提示框,一遍遍点"是"或"否"繁琐又麻烦.我看得有点不耐烦了.于是 ...

  3. html5操作类名API——classlist

    tagNode.classList.add('123'); // 添加类 tagNode.classList.remove('bbb'); // 删除类 tagNode.classList.toggl ...

  4. brk/sbrk和mmap行为分析程序

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> // #include <malloc. ...

  5. JavaEE互联网轻量级框架整合开发(书籍)阅读笔记(3):常用动态代理之JDK动态代理、CGLIB动态代理

    一.动态代理的理解 动态代理的意义在于生成一个占位(又称代理对象),来代理真实对象,从而控制真实对象的访问.        先来谈谈什么是代理模式.        假设这样一个场景:你的公司是一家软件 ...

  6. 关于在jeecms中css,图片,html,模板是如何组装成——part1

    先从HTML入手:index.html <!DOCTYPE HTML> <html> <meta name="viewport" content=&q ...

  7. Head First HTML与CSS、XHTML (中文版).(Elisabeth Freeman) PDF扫描版​

    面对那些晦涩的html书你不禁要问:“难道要成为专家之后才能读懂这些?”那么,你应该选择<head first html与css.xhtml(中文版)>真正来学习html.这本书对你来说, ...

  8. Sql 查询过慢,尝试重建索引

    DBCC showcontig('Table') DBCC DBREINDEX('Table') 分析表的索引建立情况:DBCC showcontig('Table') DBCC SHOWCONTIG ...

  9. 以太坊系列之七: p2p模块的dial--以太坊源码学习

    dial.go阅读手记 dial.go是负责和peer建立连接关系的地方,主要是实现 type dialer interface { /* peers已经有的结点 */ newTasks(runnin ...

  10. 一个简单的tcp代理实现

    There are a number of reasons to have a TCP proxy in your tool belt, bothfor forwarding traffic to b ...