cf 828A
来源:互联网 发布:手机怎么备份所有数据 编辑:程序博客网 时间:2024/06/05 07:57
点击打开链接
题意:
一个饭店有a张单人桌,b张双人座。
然后有n组人来,每组1or2人。双人只能坐双人座。
题解:
卧槽,这题又被hack 了 ,每次第一题被hack我也很无奈啊,每次被hack也是我思维漏洞的体现。。。
考虑一个点,单人优先坐单人桌,否则优先坐空的双人桌,最后考虑有人的双人桌,被hack之后,我睡了才想到只可能这里出错,
第二天交一发果然,
#include<bits/stdc++.h>#define ll long long#define mod 1000000007using namespace std;const int maxn=2e5+10;int num[maxn];int main(){ int n,a,b,c=0; int ans=0; scanf("%d %d %d",&n,&a,&b); for(int i=1;i<=n;++i) scanf("%d",&num[i]); for(int i=1;i<=n;++i){ if(num[i]==1){ if(a>0)a--; else if(b>0){ b--;c++; } else if(c>0) c--; else ans+=1; } else { if(b>0) b--; else ans+=2; } } printf("%d\n",ans); return 0;}
阅读全文
0 0
- cf 828A
- CF 2A Winner
- CF 128A Statues
- <cf>A. Exams
- CF 109A
- CF 111A
- CF 4A Watermelon
- CF 237A (Cash)
- CF 6 A - Triangle
- CF:96A.Football
- CF:208A. Dubstep
- CF:41A. Translation
- CF:59A. Word
- CF:43A. Football
- CF:78A. Haiku
- CF:A. Flipping Game
- CF 148 div1 A
- CF 127 div1 A
- 第6章 关于Greenplum的数据库统计
- caller与callee
- JAVA面试相关问题整理
- template_swap_in_c
- 菜鸟先飞之JAVA_JAVA发展史
- cf 828A
- 浅谈C++多态性
- 7.11 模拟赛
- HTTP状态码
- JDK1.6集合框架bug:c.toArray might (incorrectly) not return Object[] (see 6260652)
- js小知识
- [Leetcode] 286. Walls and Gates 解题报告
- Redis 列表 常用命令
- 敏捷教练的六顶帽子|洞见