HDU6106 Classes
2017-08-12 11:14
85 查看
【题目链接】
http://acm.hdu.edu.cn/showproblem.php?pid=6106
http://acm.hdu.edu.cn/showproblem.php?pid=6106
题目意思
给出选 A,B,C,AB,AC,BC,ABC 课程的学生,其中 AB 是 A 和 B 都选….,确定该班级的人数,给出的数据中有一些数错误的,但保证一组正确答案,输出最多的班级的人数解题思路
根据ABC的人数可以推出只选AB,AC,BC的人数,在根据前面4个可以推出只选A,B,C,的人数,总和就是这个班的人数。(保证每个都是非负数就说明给出数据合法)代码部分
#include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; const int MAX = 1e5 + 10; typedef long long LL; int main() { int T,n; scanf("%d",&T); while(T--){ int ans = 0; scanf("%d",&n); int a,b,c,ab,bc,ac,abc; for(int i = 1; i <= n; i++){ scanf("%d %d %d %d %d %d %d",&a,&b,&c,&ab,&bc,&ac,&abc); ab -= abc, ac -= abc,bc -=abc; if(ab < 0 || ac < 0 || bc < 0) continue; int aa = a - ab - ac - abc; int bb = b - ab - bc - abc; int cc = c - ac - bc - abc; if(aa < 0 || bb < 0 || cc < 0) continue; int sum = aa + bb + cc + ab + bc + ac + abc; ans = max(ans,sum); } printf("%d\n",ans); } return 0; }
相关文章推荐
- HDU6106 Classes(思路,2017 HDU多校联赛 第6场)
- hdu6106--Classes
- HDU6106 Classes 模拟|签到
- HDU6106-Classes
- HDU6106-Classes
- Hdu6106 Classes(2017多校第6场)
- C#学习基本概念---MFC(微软基础类库Microsoft Foundation Classes)
- FaceID-1:Deep Learning Face Representation from Predicting 10,000 Classes 笔记
- Error:Execution failed for task ':app:transformClassesWithDexForDebug' finished with non-zero exit v
- Maven项目pom.xml文件报xxx\target\classes\META-INF\MANIFEST.MF (系统找不到指定的路径)问题
- Error:Execution failed for task ':app:transformClassesWithDexForDebug'.问题汇总解决
- sklearn学习——SVM例程总结1(outlier and unbalanced classes)
- Android 混淆报错app:transformClassesAndResourcesWithProguardForRelease
- Android Studio常见错误之:Rendering Problems/The following classes could not be instantiated
- The Most Popular Java API Classes
- Use Size Classes
- Pure Virtual Functions and Abstract Classes in C++
- Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.tran
- eclipse import maven项目时src和classes目录不对
- Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test java.lang.IllegalStateException