# HIHO_Disk Storage

### 描述

Little Hi and Little Ho have a disk storage. The storage's shape is a truncated cone of height H. R+H is radius of top circle and R is radius of base circle.
Little Ho buys N disks today. Every disk is a cylinder of height 1. Little Ho wants to put these disk into the storage under below constraints:

1. Every disk is placed horizontally. Its axis must coincide with the axis of storage.
2. Every disk is either place on the bottom surface or on another disk.
3. Between two neighboring disks in the storage, the upper one's radius minus the lower one's radius must be less than or equal to M.

Little Ho wants to know how many disks he can put in the storage at most.

### 输入

Input contains only one testcase.
The first line contains 4 integers: N(1 <= N <= 100000), M, H, R(1 <= M, R, H <= 100000000).
The second line contains N integers, each number prepresenting the radius of a disk. Each radius is no more than 100000000.

### 输出

Output the maximum possible number of disks can be put into the storage.

5 1 10 3
1 3 4 5 10

4

R(upper)-R(lower)<=M

#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int N,M,H,R=0;
int main(){
cin>>N>>M>>H>>R;
vector<int> data(N,0);
for(int i=0;i<N;i++)
cin>>data[i];
sort(data.begin(),data.end());
int count=0;
int place=-1;
for(int i=N-1;i>=0;i--){
if(data[i]<=R){
place=i;
count++;
break;
}
}
if(place!=-1){
int i=place;
for(int j=i+1;j<N;j++){
if(((data[j]-data[j-1])<=M)&&(data[j]<= j+R))
count++;
else
break;
}
count=count+place;
}
cout<<min(count,H)<<endl;
return 0;
}

• 本文已收录于以下专栏：

## [微软苏州校招 Hihocoder] Disk Storage

#1100 : Disk Storage 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho have ...
• nisxiya
• 2015年08月12日 15:45
• 1361

## 深入理解数据库磁盘存储（Disk Storage）

• idber
• 2012年10月18日 21:21
• 23765

## 深入理解数据库磁盘存储（Disk Storage）

• qbw2010
• 2015年04月01日 08:30
• 284

## add disk to ASM(AIX RAC ASM STORAGE)

environment：AIX 6.1 + oracle 10.0.2.4  2 nodes RAC (storage HP-6100 FC disk) 1. cut 100G RAID5 FC E...

## USB Disk Storage Format Tool(U盘格式化工具)

• 2014年10月26日 21:07
• 349KB
• 下载

## HP USB Disk Storage Format Tool 2.0.6

• 2008年02月29日 16:14
• 366KB
• 下载

## Android设置里面默认存储器选项（default write disk）的实现

举报原因： 您举报文章：HIHO_Disk Storage 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)