题目链接click here~~

题目大意】n组团体去包车,每组团体的人数《=4,一辆车最多容纳4人,求所求车的数目最小

解题思路】:思路见代码~~

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif #include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime> #if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif // C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector> #if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif using namespace std;
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;++i)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;--i)
typedef long long LL;
typedef unsigned long long LLU;
typedef double db;
const int N=2*1e5+10;
LL n,m,t,ans,res,cnt,tmp; int aa[N],bb[N];
char str[N];
bool vis[N];
int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};
int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}}; int main()
{
while(cin>>n)
{
memset(aa,0,sizeof(aa));
int sum=0;
rep(i,1,n){
cin>>tmp;
aa[tmp]++;
}
printf("%d\n",((max(aa[1]-aa[3],0)+3+aa[2]*2)/4+aa[3]+aa[4]));
}
return 0;
}
/*
2组的话直接乘以2对4相除
3,4组直接放入一辆车
然后对于1组 1
比較1组和3组的大小。若大于三组。则说明将当中的1与3合并后还剩下1组,
多余的1我们如果还与3合并,由于2组已经乘以2计算,最后结果对4相除,
相加就可以
*/
/*
Sample Input
5
1 2 4 3 3
8
2 3 4 4 2 1 3 1
9
2 2 2 3 1 3 1 4 4
8
2 2 2 3 1 3 4 4
Sample Output
4
5
6
6
*/

CodeForces 158 B. Taxi(模拟)的更多相关文章

  1. Codeforces 158 B. Taxi[贪心/模拟/一辆车最多可以坐4人同一个群的小朋友必须坐同一辆车问最少需要多少辆车]

    http://codeforces.com/problemset/problem/158/B B. Taxi time limit per test 3 seconds memory limit pe ...

  2. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

  3. Codeforces 158 D

    题目链接 :http://codeforces.com/contest/158/problem/D D. Ice Sculptures time limit per test 3 seconds me ...

  4. Codeforces 626A Robot Sequence(模拟)

    A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  5. CodeForces - 589D(暴力+模拟)

    题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人 ...

  6. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  7. Codeforces 704A Thor 队列模拟

    题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡 ...

  8. Vasya And The Mushrooms CodeForces - 1016C (前缀和模拟)

    大意: 给定2*n的矩阵, 每个格子有权值, 走到一个格子的贡献为之前走的步数*权值, 每个格子只能走一次, 求走完所有格子最大贡献. 沙茶模拟打了一个小时总算打出来了 #include <io ...

  9. Codeforces 691C. Exponential notation 模拟题

    C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...

随机推荐

  1. Java反射举例

    本文參考:http://www.cnblogs.com/yydcdut/p/3845430.html 1.Java反射的基本介绍 Java的反射很强大,传递class. 能够动态的生成该类.取得这个类 ...

  2. [RxJS] Starting a Stream with SwitchMap & switchMapTo

    From an event map to another event we can use switchMap(), switchMap() accept an function which retu ...

  3. JavaScripts学习日记——BOM

    IE 3.0 和 Netscape Navigator 3.0 提供了一种特性 - BOM(浏览器对象模型),可以对浏览器窗口进行访问和操作.使用 BOM,开发者可以移动窗口.改变状态栏中的文本以及执 ...

  4. 为自己的Android应用添加广告

    平时也写了不少Android小应用,但是都是做练习之用,从来没有想过添加广告赚钱这一说. 个人是非常反感在应用内添加广告这种行为的,非常影响用户体验,不小心点到广告的话,手机流量哗哗地就没了··· 但 ...

  5. 【6】Laravel5.1的migration数据库迁移

    查看Laravel5.1的目录 当你配置好数据库后,在命令行执行下边的操作 php artisan migrate 打开数据库会发现,我们的数据库多了四个表,神奇吧! 打开任意一个migration查 ...

  6. 三个重要的游标sp_cursoropen

    請問這三個存諸過程的作用是什么﹖ sp_cursoropen, sp_cursorfetch, sp_cursorclose API 服务器游标实现  SQL Server OLE DB 提供程序. ...

  7. 2014-06-13 jq chart

    昨天接到上级说要在检测服务器上增加一个可以根据时间来查看服务器信息的线形图,那我首先就在原有的发送监控信息的功能上增加了把信息存入数据库中,然后再数据库中取得数据显示. 至于线形图的插件是jqx 的c ...

  8. http_load压力测试

    http_load是基于linux平台的性能测试工具,它体积非常小,仅100KB.它以并行复用的方式运行,可以测试web服务器的吞吐量与负载. 一.安装http_load A.进入/usr/local ...

  9. UIP协议栈

    UIP协议栈笔记 http://blog.chinaunix.net/uid-23247944-id-2974928.html

  10. Python入门学习之input()与raw_input()的区别

    登陆博客时才发现已经注册一年了,由于之前一直都没有打算从事软件开发行业,所以博客便被束之高阁,软件开发,对于我来说,是成长,更是磨炼.头脑风暴总是来去自由,记录灵感,与大家一起共享思维进步的成果. P ...