加载中...

ABC|Five Transportations


本篇博客还在持续修改润色中~

敬请期待~

AtCoder题解|ABC 123C Five Transportations


题目信息 📚

【题目描述】

In 2028, after continuous growth, AtCoder Inc. has finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!

There are five means of transport in this empire:

  1. Train: Travels from City 1 to 2 in one minute. A train can occupy at most $A$ people.
  2. Bus: Travels from City 2 to 3 in one minute. A bus can occupy at most $B$ people.
  3. Taxi: Travels from City 3 to 4 in one minute. A taxi can occupy at most $C$ people.
  4. Airplane: Travels from City 4 to 5 in one minute. An airplane can occupy at most $D$ people.
  5. Ship: Travels from City 5 to 6 in one minute. A ship can occupy at most $E$ people.

For each mode of transport, one vehicle leaves the city at each integer time (time $0, 1, 2, \ldots$).

There is a group of $N$ people at City 1, and they all want to go to City 6.

At least how long does it take for all of them to reach there? You can ignore the time needed to transfer.

【输入】

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

$N$
$A$
$B$
$C$
$D$
$E$

【输出】

Print the minimum time required for all of the people to reach City 6, in minutes.

【数据范围】

  • $1 \leq N, A, B, C, D, E \leq 10^{15}$
  • All values in the input are integers.

【输入样例1】

5
3
2
4
3
5

【输出样例1】

7

【输入样例2】

10
123
123
123
123
123

【输出样例2】

5

All kinds of vehicles can occupy $N=10$ people at a time. Thus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.

【输入样例3】

10000000007
2
3
5
7
11

【输出样例3】

5000000008

Note that the input or output may not fit into a $32$-bit integer type.

【题目来源】

https://atcoder.jp/contests/abc123/tasks/abc123_c


题目解析 🍉

【题目分析】

【C++代码】

#include<bits/stdc++.h>

using namespace std;
typedef long long LL;
LL n, cap[10];

int main() {
    // 读入数据
    cin >> n;
    for (int i = 1; i <= 5; i++) cin >> cap[i];

    // mini为最小载人数量
    LL mini = *min_element(cap + 1, cap + 1 + 5);

    // 每次都流通mini个人即可
    cout << 4 + (n + (mini - 1)) / mini << endl;

    return 0;
}

文章作者: Rickyの水果摊
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Rickyの水果摊 !
  目录