AtCoder Beginner Contest 113 B
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 T−x×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≤A≤T
- 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
2
12 5
1000 2000
Sample Output 1
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的更多相关文章
- AtCoder Beginner Contest 113 C
C - ID Time limit : 2sec / Memory limit : 1024MB Score: 300 points Problem Statement In Republic of ...
- AtCoder Beginner Contest 113 D Number of Amidakuji
Number of Amidakuji 思路:dp dp[i][j]表示经过(i, j) 这个点的方案数 然后一层一层地转移, 对于某一层, 用二进制枚举这一层的连接情况, 判断连接是否符合题意, 然 ...
- AtCoder Beginner Contest 113 A
A - Discount Fare Time limit : 2sec / Memory limit : 1024MB Score: 100 points Problem Statement Ther ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
随机推荐
- PHP+SOCKET 模拟HTTP请求
HTTP消息结构 客户端请求包括四部份:请求行(状态行).请求头.空行.请求主体(数据),如下图: 服务端响应包括四部份:响应行(状态行).响应头.空行.响应主体(数据),如图: HTTP请求方法: ...
- 2.2开源的魅力:编译opencv源代码
1.下载安装CMake 要在Windows平台下生成opencv的解决方案,需要一个名为CMake的开源软件.CMake的全称是crossplatform make.它是一个跨平台的安装(编译)工具, ...
- docker入门及安装
Docker简介 Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机).ba ...
- Orace开源的异步IO编程库,特点是接口非常简单
官网:https://oss.oracle.com/projects/libaio-oracle/,正如标题所说,非常简单了,不用多解释,请直接看头文件,其中aio_poll类似于poll,重要的结构 ...
- .Net 数据库(SqlServer2008)的备份、还原
//备份代码private void Backup() { SqlConnection sqlConn = new SqlConnection(strConn); strFileName = &quo ...
- Head First HTML与CSS、XHTML (中文版).(Elisabeth Freeman) PDF扫描版
面对那些晦涩的html书你不禁要问:“难道要成为专家之后才能读懂这些?”那么,你应该选择<head first html与css.xhtml(中文版)>真正来学习html.这本书对你来说, ...
- 记.gitignore的一次惊心动魄
git rm -r --cached . #清除缓存 git add . #重新trace file git commit -m "update .gitignore" #提交和 ...
- 使用CodeMaid自动程序排版[转]
前言 「使用StyleCop验证命名规则」这篇文章,指引开发人员透过StyleCop这个工具,来自动检验项目中产出的程序代码是否合乎命名规则. [Tool] 使用StyleCop验证命名规则 但是在项 ...
- MQ入门总结(一)消息队列概念和使用场景
一.消息队列 消息即是信息的载体.为了让消息发送者和消息接收者都能够明白消息所承载的信息(消息发送者需要知道如何构造消息:消息接收者需要知道如何解析消息),它们就需要按照一种统一的格式描述消息,这种统 ...
- SpringMVC+Hibernate 项目开发之三 (创建SpringMVC项目)
引用(很全面了):http://blog.csdn.net/dhx20022889/article/details/38041039 我只想说默认创建的项目使用的Spring版本可能不是你想要的,可以 ...