A1062 Talent and Virtue (25)
2015-08-07 15:55
363 查看
未完成的代码
#include<cstdio> #include<algorithm> using namespace std; struct Grade{ int num,de,cai,sum,flag; }stu[100010]; bool cmp(Grade a,Grade b){ if(a.flag!=b.flag) return a.flag < b.flag; else if(a.sum!=b.sum) return a.sum > b.sum; else if(a.de!=b.de) return a.de > b.de; else return a.num < b.num; } int main(){ int n,l,h,m = 0; scanf("%d %d %d",&n,&l,&h); for(int i =0;i < n;i++){ scanf("%d %d %d",&stu[i].num,&stu[i].de,&stu[i].cai); stu[i].sum = stu[i].de + stu[i].cai; if(stu[i].de>=h && stu[i].cai >= h) stu[i].flag = 1; else if(stu[i].de >= h&&stu[i].cai >= l&&stu[i].cai<h) stu[i].flag = 2; else if(stu[i].cai>=l&&stu[i].cai< h && stu[i].de>=stu[i].cai&&stu[i].de>=l&&stu[i].de<h) stu[i].flag = 3; else if(stu[i].de<l || stu[i].cai < l){ stu[i].flag = 5; } else stu[i].flag = 4; } sort(stu,stu+n,cmp); while(stu[m].flag<5 && m<=n) m++; printf("%d\n",m); for(int i = 0;i < m;i++) printf("%d %d %d\n",stu[i].num,stu[i].de,stu[i].cai); return 0; }
相关文章推荐
- requireJS使用
- (绝对有用)iOS获取UUID,并使用keychain存储
- ueditor在QQ浏览器或者IE浏览器中无法加载
- ueditor在QQ浏览器或者IE浏览器中无法加载
- UICollectionView的使用
- 双飞翼布局介绍-始于淘宝UED
- Field 'id' doesn't have a default value
- UIView添加动画
- IOS第八天(1:UITableViewController团购,数据转模型,xib显示数据)
- 说说SAP Business One怎么样
- UIScrollView实现图片浏览
- 造成ORA-01843 无效的月份 的一些原因 1) 当我们在一个中文环境的客户端使用如下sql语句 INSERT INTO "temptable" ( DELIVER_DATE ) VALUES
- (三) Build Task(构建任务)
- (一) Simple build files(简单的构建文件)
- 自定义UINavigationController的后退按钮标题
- 关于work queue 中出现的INIT_WORK 参数问题
- Proving Equivalences UVALive 4287 图的强连通分量
- hdu1711 Number Sequence(KMP水题)
- 使用SetCurrentRowWithKeyValue
- easyui-validatebox和easyui-textbox赋值的区别