hdu 6106 Classes
Classes
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 290 Accepted Submission(s): 187
Now the school wants to count the number of students who enrolled in at least one course in each class and records the maximum number of students.
Each class uploaded 7 data, the number of students enrolled in course A in the class, the number of students enrolled in course B, the number of students enrolled in course C, the number of students enrolled in course AB, the number of students enrolled in course BC, the number of students enrolled in course AC, the number of students enrolled in course ABC. The school can calculate the number of students in this class based on these 7 data.
However, due to statistical errors, some data are wrong and these data should be ignored.
Smart you must know how to write a program to find the maximum number of students.
Each case begins with one line with one integer N, indicates the number of class.
Then N lines follow, each line contains 7 data: a, b, c, d, e, f, g, indicates the number of students enrolled in A, B, C, AB, BC, AC, ABC in this class.
It's guaranteed that at least one data is right in each test case.
Limits
T≤100
1≤N≤100
0≤a,b,c,d,e,f,g≤100
In the second test case, the data uploaded by Class 1 is wrong. Because we can't find a solution which satisfies the limitation. As for Class 2, we can calculate the number of students who only enrolled in course A is 2, the number of students who only enrolled in course B is 6, and nobody enrolled in course C, the number of students who only enrolled in courses A and B is 1, the number of students who only enrolled in courses B and C is 3, the number of students who only enrolled in courses A and C is 1, the number of students who enrolled in all courses is 2, so the total number in Class 2 is 2 + 6 + 0 + 1 + 3 + 1 + 2 = 15.
现在,学校想计算每班入读至少一门课程的学生人数,并记录最多学生人数。
每班上传7份资料,在每班中,选课程A的学生人数,选课程B的学生人数,选课程C的学生人数,选课程AB的学生人数,选课程BC的学生人数,选课程AC的学生人数,选课程ABC的学生人数。根据这7个数据,学校可以计算这个班级的学生人数。
题解:判断条件不充裕导致wa,最后三个条件容易忽视
#include <iostream> #include<cstdio> #include<algorithm> #include<queue> #include<map> #include<vector> #include<cmath> #include<cstring> #include<bits/stdc++.h>using namespace std; int t,n,a,b,c,ab,bc,ac,abc; int ans;int main() {scanf("%d",&t);for(;t>0;t--){scanf("%d",&n);ans=0;for(int i=1;i<=n;i++){scanf("%d%d%d%d%d%d%d",&a,&b,&c,&ab,&bc,&ac,&abc);if( ab<=a && ab<=b && bc<=b && bc<=c && ac<=a && ac<=c &&abc<=ab && abc<=ac && abc<=bc&& ab+ac-abc<=a && bc+ac-abc<=c && ab+bc-abc<=b){ans=max(ans,a+b+c-ab-bc-ac+abc);}}printf("%d\n",ans);}return 0; }
转载于:https://www.cnblogs.com/stepping/p/7344089.html
hdu 6106 Classes相关推荐
- hdu 6106 Classes (二分)
怎么说呢,多校看完题解总让你感觉难度还可以,不算大,题解能看懂,让你自己做呢,这题什么意思?怎么办?什么思路?也许这就是多校的魅力和意义所在,还好有很多人都不会,看了题解就开始疯狂补题.首先这个题我没 ...
- 暑期集训3:几何基础 练习题G: HDU - 1052
2018学校暑期集训第三天--几何基础 练习题G -- HDU - 1052 (昨天加练题) Tian Ji -- The Horse Racing Here is a famous sto ...
- HDU杭电OJ经典100题2000-2099_Java版详细题解(持续更新)
今年寒假打算用Java把杭电2000-2099全部AC(现在持续更新),如下是题目链接,之后是我的题解,全部做完后我会把所有AC的题解打包上传的 题号 题名 题号 题名 2000 ASCII码排序 2 ...
- HDU 4389 - X mod f(x)
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4389 2012多校,第9场,1010 . 问题是,询问区间内 存在多少个 哈沙德数(Harshad ...
- 杭电1042c语言循环,HDU杭电1052 Tian Ji - The Horse Racing答题报告
HDU杭电1052 Tian Ji -- The Horse Racing解题报告 本人第一次写博客,希望各位大神多多指导与包涵,不足的地方还请指出,新手在此谢过啦!!! 题目描述: Time Lim ...
- hdu 4389 囧,打表
http://acm.hdu.edu.cn/showproblem.php?pid=4389 题意 :一个数能被他各个位数之和整除则符合要求,给L,R,问区间里有多少个数符合要求. 囧,居然打表就能过 ...
- MinkowskiEngine Miscellaneous Classes杂类
Miscellaneous Classes杂类 内核生成器 class MinkowskiEngine.KernelGenerator(kernel_size = -1,stride = 1,dila ...
- HDU——1106排序(istringstream的使用、STLvector练习)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...
- hdu 5438 Ponds 拓扑排序
Ponds Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_showproblem ...
最新文章
- POJ-3662 Telephone Lines 二分+双端队列
- C语言 | 编程实现5
- 五、python模块以及包
- Windows之Xmanager连接linux打开Oracle视图操作
- (组合数学笔记)Pólya计数理论_Part.4_Burnside引理
- 结构体含有指针的写入文件
- win11系统卡死怎么办 Windows11系统卡死的解决方法
- Linux下网站搭建(2)---Mysql安装和基本操作
- Reinforcement Learning[论文合集]
- fanuc系统网络服务器,FANUC的网络配置.doc
- 红米note7android10,红米Note7 Pro 安卓10.0原生刷机包(最新固件升级包lineage17.1)
- 无人机飞行控制算法、控制律设计软件与半物理仿真
- C++ 实现CRC循环冗余校验码
- [模板]线性递推+BM
- 为什么char+char为int类型 C/C++类型提升
- vue+element-ui调用后台接口实现excel在线预览
- 《算法图解》读书笔记
- codevs 1907:方格取数3
- Arcgis打开.dat文件
- 如何使img或者div在div中水平垂直居中显示