AtCoder题解 —— AtCoder Beginner Contest 185 —— A - ABC Preparation
作者:互联网
题目相关
题目链接
AtCoder Regular Contest 185 A 题,https://atcoder.jp/contests/abc185/tasks/abc185_a。
Problem Statement
Takahashi has decided to hold some number of programming contests.
Holding one contest requires one 100-point problem, one 200-point problem, one 300-point problem, and one 400-point problem.
When he has A1, A2, A3, and A4 drafts of 100-, 200-, 300-, and 400-point problems, respectively, at most how many contests can he hold?
The same draft can be used only once.
Input
Input is given from Standard Input in the following format:
A1 A2 A3 A4
Output
Print an integer representing the maximum number of contests that can be held.
Samples1
Sample Input 1
5 3 7 11
Sample Output 1
3
Explaination
By using three drafts for each slot, he can hold three contests. He has just three drafts for 200-point problems, so he cannot hold four.
Samples2
Sample Input 2
100 100 1 100
Sample Output 2
1
Constraints
- 1≤Ai≤100 (1≤i≤4)
- All values in input are integers.
题解报告
题目翻译
高桥决定完成算法竞赛,完成算法竞赛需要完成一个 100 分问题、一个 200 分问题、一个 300 分问题和一个 400 分问题。当他有 A1、A2、A3 和 A4 四种草案分别针对 100分、200分、300分和 400 分。问做多有多少个竞赛可以完成,同一个草案只能使用一次。
题目分析
又是一个友善的打卡数学题。找四个数的最小值就是答案。勤快一点自己写一个 min 函数,偷懒一点直接使用 STL 的 min 函数即可。
数据范围估计
[1, 100] 的范围,用 int 就可以了。
AC 代码
#include <bits/stdc++.h>
using namespace std;
//如果提交到OJ,不要定义 __LOCAL
//#define __LOCAL
int main() {
#ifndef __LOCAL
//这部分代码需要提交到OJ,本地调试不使用
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#endif
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<min({a,b,c,d})<<"\n";
#ifdef __LOCAL
//这部分代码不需要提交到OJ,本地调试使用
system("pause");
#endif
return 0;
}
时间复杂度
O(1)。
空间复杂度
O(1)。
标签:AtCoder,200,ABC,point,题解,400,Input,100,contests 来源: https://blog.csdn.net/justidle/article/details/111147031