BIT 1004 Who is the Smartest Man
来源:互联网 发布:中国为什么不禁烟 知乎 编辑:程序博客网 时间:2024/06/05 03:57
Bit 5
题目大意:给你曹操的攻击力和N(N<=500)个小怪,每战胜一个攻击力比他低的小怪他的攻击力就加1,战胜一个攻击力比他高的小怪就加2。现在给出N个小怪的攻击力,请问他最后的攻击力最高是多少
考察点:贪心
思路分析:显然,把小怪攻击力排序一下,先打攻击力比自己高的小怪中攻击力最低的那个,最后再打攻击力一开始就比自己低的。
交了三次AC。。输入有多组数据,没打while。。。
#include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ int n,ip,i,j; int a[510]; while(~scanf("%d%d",&n,&ip)) { for (i=1;i<=n;i++) scanf("%d",&a[i]); for (i=1;i<=n-1;i++) { for (j=i+1;j<=n;j++) { if (a[i]>a[j]) { a[0]=a[i];a[i]=a[j];a[j]=a[0]; } } } j=0; for (i=1;i<=n;i++) { if (a[i]<=ip) j++; else ip=ip+2; } ip=ip+j; printf("%d\n",ip);} system("pause"); return 0; }
- BIT 1004 Who is the Smartest Man
- bit Who is the Smartest Man
- Who is the Smartest Man
- BIT寒假练习-2013__1004:Who is the Smartest Man
- 2013寒假练习 1004:Who is the Smartest Man
- 寒假练习 1004 Who is the Smartest Man
- zoj3519 Who is the Smartest Man//贪心
- zoj 3519 Who is the Smartest Man
- zoj 3519 Who is the Smartest Man
- ZOJ3519 BIT1004 Who is the Smartest Man
- Who is the Smartest Man 解题报告
- ZOJ 3519 Who is the Smartest Man(贪心)
- ZOJ-#3519 Who is the Smartest Man(贪心)
- ZOJ 3519 Who is the Smartest Man (贪心)
- ZOJ 3519 Who is the Smartest Man(水水的贪心)
- 324.Nothing is difficult to the man who will try. 世上无难事,只要肯攀登
- 197. Happy is the man who learns from the misfortunes of others.吸取他人的教训,自己才会走运
- who is the real hero!
- BIT 1001 Average Numbers
- python 网络编程1
- Error Provider Cannot display &
- BIT 1003 Exchange for Cola
- git学习笔记(2)-创建仓库、更新代码
- BIT 1004 Who is the Smartest Man
- BIT 1005 穿越沙漠
- apache+php+mysql+phpmyadmin 自定义安装配置环境
- BIT 1006 The most frequent number
- 站在巨人的肩膀上--学习用例图(UML)
- a File Switch Tabbar for Source Insight
- Python脚本实现Mac开机自动语音播报天气
- scanf();需要注意的几点
- BIT 1007 Number Converter