Classes

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 290    Accepted Submission(s): 187

Problem Description
The school set up three elective courses, assuming that these courses are A, B, C. N classes of students enrolled in these courses.
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.
Input
The first line of the input gives the number of test cases T; T test cases follow.
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

Output
For each test case output one line contains one integer denotes the max number of students who enrolled in at least one course among N classes.
Sample Input
2
2
4 5 4 4 3 2 2
5 3 1 2 0 0 0
2
0 4 10 2 3 4 9
6 12 6 3 5 3 2

Sample Output
7
15
Hint

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.

Source
2017 Multi-University Training Contest - Team 6
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6107 6106 6105 6104 6103 

题意:
学校设立了三门选修课程,假设这些课程是A,B,C。N个班的学生参加了这些课程。
现在,学校想计算每班入读至少一门课程的学生人数,并记录最多学生人数。
每班上传7份资料,在每班中,选课程A的学生人数,选课程B的学生人数,选课程C的学生人数,选课程AB的学生人数,选课程BC的学生人数,选课程AC的学生人数,选课程ABC的学生人数。根据这7个数据,学校可以计算这个班级的学生人数。
现在给你n个班的数据,有些班的数据是错误的,我们应判断出来并忽视它,在剩下数据对的班级里,利用给出的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相关推荐

  1. hdu 6106 Classes (二分)

    怎么说呢,多校看完题解总让你感觉难度还可以,不算大,题解能看懂,让你自己做呢,这题什么意思?怎么办?什么思路?也许这就是多校的魅力和意义所在,还好有很多人都不会,看了题解就开始疯狂补题.首先这个题我没 ...

  2. 暑期集训3:几何基础 练习题G: HDU - 1052

    2018学校暑期集训第三天--几何基础 练习题G  --   HDU - 1052   (昨天加练题) Tian Ji -- The Horse Racing Here is a famous sto ...

  3. HDU杭电OJ经典100题2000-2099_Java版详细题解(持续更新)

    今年寒假打算用Java把杭电2000-2099全部AC(现在持续更新),如下是题目链接,之后是我的题解,全部做完后我会把所有AC的题解打包上传的 题号 题名 题号 题名 2000 ASCII码排序 2 ...

  4. HDU 4389 - X mod f(x)

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4389 2012多校,第9场,1010 . 问题是,询问区间内 存在多少个 哈沙德数(Harshad ...

  5. 杭电1042c语言循环,HDU杭电1052 Tian Ji - The Horse Racing答题报告

    HDU杭电1052 Tian Ji -- The Horse Racing解题报告 本人第一次写博客,希望各位大神多多指导与包涵,不足的地方还请指出,新手在此谢过啦!!! 题目描述: Time Lim ...

  6. hdu 4389 囧,打表

    http://acm.hdu.edu.cn/showproblem.php?pid=4389 题意 :一个数能被他各个位数之和整除则符合要求,给L,R,问区间里有多少个数符合要求. 囧,居然打表就能过 ...

  7. MinkowskiEngine Miscellaneous Classes杂类

    Miscellaneous Classes杂类 内核生成器 class MinkowskiEngine.KernelGenerator(kernel_size = -1,stride = 1,dila ...

  8. HDU——1106排序(istringstream的使用、STLvector练习)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

  9. hdu 5438 Ponds 拓扑排序

    Ponds Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_showproblem ...

最新文章

  1. POJ-3662 Telephone Lines 二分+双端队列
  2. C语言 | 编程实现5
  3. 五、python模块以及包
  4. Windows之Xmanager连接linux打开Oracle视图操作
  5. (组合数学笔记)Pólya计数理论_Part.4_Burnside引理
  6. 结构体含有指针的写入文件
  7. win11系统卡死怎么办 Windows11系统卡死的解决方法
  8. Linux下网站搭建(2)---Mysql安装和基本操作
  9. Reinforcement Learning[论文合集]
  10. fanuc系统网络服务器,FANUC的网络配置.doc
  11. 红米note7android10,红米Note7 Pro 安卓10.0原生刷机包(最新固件升级包lineage17.1)
  12. 无人机飞行控制算法、控制律设计软件与半物理仿真
  13. C++ 实现CRC循环冗余校验码
  14. [模板]线性递推+BM
  15. 为什么char+char为int类型 C/C++类型提升
  16. vue+element-ui调用后台接口实现excel在线预览
  17. 《算法图解》读书笔记
  18. codevs 1907:方格取数3
  19. Arcgis打开.dat文件
  20. 如何使img或者div在div中水平垂直居中显示

热门文章

  1. Css 特殊或不常用属性
  2. WinPE ISO制作
  3. [windows]windows 10 锁屏壁纸保存方法
  4. 单位脉冲信号与单位冲激信号的区别
  5. mapPartition方法与map方法的区别(转载)
  6. linux下面的浏览器不停自动打开新网页
  7. 矩阵行列式的几何意义验证
  8. matlab计算hessian矩阵
  9. intellij关联本地的maven的repository
  10. Fatal error compiling: 无效的目标发行版: 3.1