• 问题 E: Airport Bus 时间限制: 2 Sec 内存限制: 256 MB 提交: 105 解决: 50 [提交] [状态] [讨论版] [命题人:admin] 题目描述 Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives ...

问题 E: Airport Bus
时间限制: 2 Sec 内存限制: 256 MB
提交: 105 解决: 50
[提交] [状态] [讨论版] [命题人:admin]
题目描述
Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time Ti.

Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between Ti and Ti+K (inclusive).

When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Constraints
2≤N≤100000
1≤C≤109
1≤K≤109
1≤Ti≤109
C, K and Ti are integers.

输入
The input is given from Standard Input in the following format:

N C K
T1
T2
:
TN

输出
Print the minimum required number of buses.

样例输入
复制样例数据
5 3 5
1
2
3
6
12
样例输出
3

提示
For example, the following three buses are enough:
A bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.
A bus departing at time 6, that carries the passengers arriving at time 1 and 6.
A bus departing at time 12, that carries the passenger arriving at time 12.

思路：就是一个贪心或者说是模拟，要么车满，要么时间到了。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int N=100000+5;
int t[N];
int n,k,c;
int main()
{
int p=1,cnt=1,ti;
scanf("%d%d%d",&n,&c,&k);
for(int i=1;i<=n;i++)
scanf("%d",&t[i]);
sort(t+1,t+n+1);
ti=t[1]+k;
for(int i=2;i<=n;i++)
{
if(t[i]>ti||p==c)//时间过了或者车满了
{
cnt++;
ti=t[i]+k;
p=1;
}
else
p++;
}
printf("%d",cnt);
}

展开全文
• 题意： 解法： 将时间从小到大排序,显然选择相邻一段最优, 从左开始贪心选择,当时间差>K或者人数超过C则再来一辆车. code： #include <bits/stdc++.h> #define int long long #define PI pair<...

#### 解法：

将时间从小到大排序,显然选择相邻一段最优,
从左开始贪心选择,当时间差>K或者人数超过C则再来一辆车.

#### code：

#include <bits/stdc++.h>
#define int long long
#define PI pair<int,int>
using namespace std;
const int maxm=2e6+5;
int a[maxm];
int n,c,k;
void solve(){
cin>>n>>c>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+1+n);
int ans=0;
int st=-1e18;
int cnt=0;
for(int i=1;i<=n;i++){
if(a[i]>st+k||cnt+1>c){
ans++;
cnt=1;
st=a[i];
}else{
cnt++;
}
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0);
solve();
return 0;
}

展开全文
• Bayan Bus The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row an...

# Bayan Bus

The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows.

The event coordinator has a list of k participants who should be picked up at the airport. When a participant gets on the bus, he will sit in the last row with an empty seat. If there is more than one empty seat in that row, he will take the leftmost one.
In order to keep track of the people who are on the bus, the event coordinator needs a figure showing which seats are going to be taken by k participants. Your task is to draw the figure representing occupied seats.

input
The only line of input contains integer k, (0 ≤ k ≤ 34), denoting the number of participants.
output
Print the figure of a bus with k passengers as described in sample tests. Character ‘#’ denotes an empty seat, while ‘O’ denotes a taken seat. ‘D’ is the bus driver and other characters in the output are for the purpose of beautifying the figure. Strictly follow the sample test cases output format. Print exactly six lines. Do not output extra space or other characters.
Examples
Input
9
output
±-----------------------+
|O.O.O.#.#.#.#.#.#.#.#.|D|)
|O.O.O.#.#.#.#.#.#.#.#.|.|
|O…|
|O.O.#.#.#.#.#.#.#.#.#.|.|)
±-----------------------+
input
20
output
±-----------------------+
|O.O.O.O.O.O.O.#.#.#.#.|D|)
|O.O.O.O.O.O.#.#.#.#.#.|.|
|O…|
|O.O.O.O.O.O.#.#.#.#.#.|.|)
±-----------------------+
题意：题意很简单，输入一个数，这个数代表上车人数，每次上车都从左边靠窗坐，直至坐满。
方法：看到这道题的输出有很多固定的字符，首先想到可以用strcpy数组来存好，然后看上了几个人就改变九个位置。

#include"cstdio"
#include"cstring"
#include"iostream"
#include"algorithm"
using namespace std;
int main()
{
int n;
while(cin>>n)
{
char a[7][28];
strcpy(a[0],"+------------------------+");
strcpy(a[1],"|#.#.#.#.#.#.#.#.#.#.#.|D|)");
strcpy(a[2],"|#.#.#.#.#.#.#.#.#.#.#.|.|");
strcpy(a[3],"|#.......................|");
strcpy(a[4],"|#.#.#.#.#.#.#.#.#.#.#.|.|)");
strcpy(a[5],"+------------------------+");
for(int i=0;i<=22;i++)
{
for(int j=0;j<6;j++)
{
if(a[j][i]=='#')
{
a[j][i]='0';
n--;
if(!n)
{
break;
}
}
}
if(!n)
{
break;
}
}
for(int i=0;i<6;i++)
{
cout<<a[i]<<endl;
}
}
return 0;
}

展开全文
• What’s Gabiluso needs to do is destroying some bus stations to make the army can’t get to the airport in k minutes. It takes exactly one minute for a bus to pass any road. All bus stations are ...
• 2013-02-04 下面学习一些airport 的英语： 1Firstly, let us study some worlds: Passengers: (a person in a car or on a bus, train, or plane) departure: (The act of leaving a place) example: The ...

2013-02-04 下面学习一些airport 的英语：

1Firstly, let us study some worlds:

Passengers:
(a person in a car or on a bus, train, or plane)

departure:
(The act of leaving a place)
example:
The list of departure tells you when the flights are leaving.

flight attendant:
(a person who helps passengers on a plane)
example:
Ask the flight attendant to get you a blanket.

gate:
(the plce in an airport where you leave the building and enter the plane)
example:
We need to find out which gate our flight leaves from, let's check the screen.

documents:
(an offical paper)
example:
I have all my travel documents; my tickets; passport,and visa.

immigration:
(the system of deciding who can enter a country, OR the place where someone checks the passports and other papers of people coming into the country)
example:
In some countries, you can get your visa at immigration as you enter the conutry.

baggage claim:
(the place where you get your luggage)
example:
I'll go to baggage claim to get my suitcase, then I will meet you outside.

at customs:
(the system of controlling items people bring into a foreign conutry, or the place where luggage is checked when you enter a foreign country.)

下面来练习一下：
1：Our arrival in HongKong was right on time.
2: Please listen to the safety instructions given by the flight attendant.
3: Before we get on plane, we have to wait at the gate.
4: This flight is full, there are many passengers on the plane.
5: Please take your seats so we can have on-time departure to Los-angeles
6: Here are all of the documents for yor visa.
7: Before he went to customes, Andy got his bags at baggage claim.
8: You must show your passport at immigration when you enter a new country.
9: I don't see our flight on the schedule display anymore. I hope it is not cancelled.
10: Do not bring your computer on vaction. The purpose of this trip is to relax, not to work.
11: Airline worker: Do you want a one-way ticket to Bombay?
Customer: No I'd like a round-trip ticket, please. I want to come back next wek.
12: When you enter a country, you have to tell what thing you are bring with you, you can declare things at customs.

展开全文
• The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats ...
• Bayan Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The final round of Bayan Programming Contest w
• Bayan Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The final round of Bayan Programming Contest w
• Destroying the bus stations Time Limit:1000MS Memory Limit:65536K Total Submissions:1832 Accepted:595 Description Gabiluso is one of the greatest spies in his count...
• Bayan Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The final round of Bayan Programming Contest w
• 口语笔记B1-Unit7.交通出行-01-Scheduling a ride to the airportScheduling a ride to the ...a bus ride 行程，旅行 pick-up接人drop-off terminal航站楼 Domestic Arrivals国内到达 In that case那样的话 accomm
• Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2930 Accepted Submission(s): 979 Problem Description
• Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3688 Accepted Submission(s): 1253 Problem Description Gabiluso i...
•  participants who should be picked up at the airport. When a participant gets on the bus, he will sit in the last row with an empty seat. If there is more than one empty seat in that row, he will ...
• A - Airport Bus 贪心，能取就取。 1 //waz 2 #include <bits/stdc++.h> 3 4 using namespace std; 5 6 #define mp make_pair 7 #define pb push_back 8 #define fi first 9 #define ...
• Bayan Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The final round of Bayan Programming Contest w
• Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1130Accepted Submission(s): 333 Problem Description Gabiluso ...
• Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3140 Accepted Submission(s): 1045 Problem Description
• What's Gabiluso needs to do is destroying some bus stations to make the army can't get to the airport in k minutes. It takes exactly one minute for a bus to pass any road. All bus stations are ...
• A - Airport Bus 大意：有N个人，每个人只能在$$[T_i,T_i +K]$$这段区间乘车，每辆车安排C人，问最少安排几辆车 直接扫，遇到一个没有车的在$$T_i +K$$分配一辆 #include <iostream> #include <algorithm&...
• A - Airport Bus 贪心选择即可… #include&amp;amp;amp;lt;bits/stdc++.h&amp;amp;amp;gt; using namespace std; #define RI register int int read() { int q=0;char ch=' '; while(ch&amp;amp;amp;...
• A - Airport Bus 从后往前贪心即可。 #include<bits/stdc++.h> using namespace std; const int N=100010; int a[N],n,c,k; int main(){ scanf("%d %d %d",&n,&c,&k); for(int i=1;i<=n;i+...
• Destroying the bus stations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2266   Accepted: 715 Description Gabiluso is one of the greatest spies in...
• What’s Gabiluso needs to do is destroying some bus stations to make the army can’t get to the airport in k minutes. It takes exactly one minute for a bus to pass any road. All bus stations are ...

...