codeforces-#465B. Inbox (100500)(模拟)
来源:互联网 发布:阿里巴巴标题优化技巧 编辑:程序博客网 时间:2024/06/01 09:35
题目大意:给出邮件箱已读和未读的邮件状态以及分布情况,求最少还需要点击多少次才能读完。
解题思路:模拟裸题,直接按照题目的要求进行模拟即可,注意末尾有0的判断,这里输入的时候记下所有的1,然后后面有两个0的时候,直接看1被读完没?没读完则说明要点击返回列表继续,需要加加,否则不加。
题目来源:http://codeforces.com/problemset/problem/465/B
code:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MAXN =1000+10;int n,ans;int str[MAXN];int main(){ while(scanf("%d",&n)!=EOF){ ans=0; int k=0,count=0; memset(str,0,sizeof(str)); for(int i=0;i<n;i++){ scanf("%d",&str[i]); if(str[i]==1) count++; } for(int i=0;i<n;){ if(str[i]==1){ ans++; k++; if(str[i+1]==0 && str[i+1]==1){ ans++;i+=2; } if(str[i+1]==0 && str[i+1]==0 && count!=k){ ans++;i+=2; } else i++; } else i++; } printf("%d\n",ans); } return 0;}
0 0
- codeforces-#465B. Inbox (100500)(模拟)
- [Codeforces] 465B - Inbox (100500)
- Codeforces 465B Inbox (100500)
- Codeforces Round #265 (Div. 2) B. Inbox (100500)(模拟)
- 【CODEFORCES】 B. Inbox (100500)
- Codeforces 465B Inbox (100500)(水题)
- Codeforces Round #265 (div2) B. Inbox (100500)
- Codeforces Round #265 (Div. 2) B. Inbox (100500)
- B. Inbox (100500)
- CodeForces 754B(模拟)
- codeforces 839B(模拟)
- Inbox (100500)
- codeforces-#469B. Chat Online(模拟)
- codeforces-#479B. Towers(模拟)
- CodeForces 1B. Spreadsheets(模拟)
- codeforces - 578B - "Or" Game(模拟)
- Educational Codeforces Round 6 (B)模拟
- Educational Codeforces Round 7(B)模拟
- MVC一个入门的例子(二)
- Reactor模式和NIO
- [leetcode] 3Sum
- codeforces-#465A. inc ARG(模拟)
- 【个人机房重构】——限制字符串输入(正则表达式)
- codeforces-#465B. Inbox (100500)(模拟)
- ServletContext方法实例讲解
- 我的linux内核学习之路(送新手)
- 查看linux服务器硬盘IO读写负载
- 开心的小明
- Android 中ScrollView的使用
- top命令分析
- Android 无标题 全屏设置
- 理解Load Average做好压力测试