cf158B(水题)
题意:1辆出租车可以坐4人,已知k组人每组ki(ki<=4)人去坐车,要求同组人坐同一辆车,求最少需多少辆车。。
4人组的单独算,1人组和3人组一起,如1多余再将1和2匹配即可。。。。
代码如下:
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std; int main(void)
{
int n, ans=;
int a[];
cin >> n;
memset(a, , sizeof(a));
while(n--)
{
int x;
cin >> x;
a[x]++;
}
if(a[]>a[])
{
ans+=a[];
a[]-=a[];
if(a[]>a[])
{
ans+=floor(a[]*1.0/+0.5);
a[]-=floor(a[]*1.0/+0.5);
ans+=floor(a[]*1.0/+0.75);
}
else
{
ans+=a[];
a[]-=*a[];
ans+=floor(a[]*1.0/+0.75);
}
ans+=a[];
}
else
{
ans+=a[];
a[]-=a[];
ans+=a[];
ans+=a[];
ans+=floor(a[]*1.0/+0.75);
}
cout << ans << endl;
return ;
}
cf158B(水题)的更多相关文章
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
随机推荐
- jsp学习(五)
在进行jsp与jdbc连接时,出现这样一个错误,提示如下: java.net.ConnectException: Connection refused: connect 后来发现是由于mysql数据库 ...
- “面向对象"和"面向过程"到底有什么区别?
链接:http://www.zhihu.com/question/27468564/answer/101951302 当软件还非常简单的时候,我们只需要面向过程编程: 定义函数函数一函数二函数三函数四 ...
- MySQL逻辑备份与恢复
备份:mysqldump -uroot -p yyzc department > /home/admin/yyzc_backup.sql 恢复:mysql -uroot -p yyzc < ...
- Egret命令行小结
1. build 构建指定项目,编译指定项目的TypeScript文件2. create 创建新项目3. create_app 从h5游戏生成app4. create_mainfest 在工程目录下生 ...
- linux 优化&安全运维&黑客攻防
优化: 可删除用户:adm,lp,sync,shutdown,halt,news,uucp,operator,games,gopher. :userdel games 可删除组:adm,lp,ne ...
- DataTable中如何去除重复的项
DataView dv =dataTable.DefaultView; DataTable dt = dv.ToTable(true, "Name");
- ASP.NET MVC 随想录——开始使用ASP.NET Identity,初级篇(转)
ASP.NET MVC 随想录——开始使用ASP.NET Identity,初级篇 阅读目录 ASP.NET Identity 前世今生 建立 ASP.NET Identity 使用ASP.NET ...
- 10 steps to becoming the developer everyone wants
You thought it was all about programming skills. But you were wrong! Great code is fine, yet command ...
- matlab之waitbar() delete() close()
matlab之waitbar() delete() close() 三者之间的关系: 在显示某个程序的进度时,用waitbar函数显示进度条,当程序进行完毕时,用close 或 delete函数关闭此 ...
- 繁华模拟赛 ljw搭积木
#include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...