题目出处:http://codeforces.com/problemset/problem/892/B

题目大意:一队人同时举刀捅死前面一些人后还活着几个

#include<iostream>
#define IO ios::sync_with_stdio(false);\
  cin.tie(0);\
  cout.tie(0);
using namespace std;
typedef __int64 LL;
const int maxn = 2e6+;
int p[maxn]; //库中有max同名
int main(){
IO;//输入输出流加速
int n;cin>>n;
for(int i=;i<n;i++) cin>>p[i];
LL cnt=p[n-], ans=;
for(int i=n-; i>=; i--){
if(!cnt) ans++;
cnt = (cnt-)>p[i]?(cnt-):p[i];
}
cout<<ans<<endl;
return ;
}

本题题目解题思路并不难,但是在测试的时候多次超时,然后看了别人的代码,在此体现了cin/cout的慢节奏

解决办法就是加入两行代码

#define IO ios::sync_with_stdio(false);\cin.tie(0);\cout.tie(0);
IO;//输入输出流加速
详细原因百度都可以查到。

892B. Wrath#愤怒的连环杀人事件(cin/cout的加速)的更多相关文章

  1. acdream B - 郭式树 (水题 卡cin,cout, 卡LL)

    题目 输入正好是long long的最大, 但是答案超long long 所以用unsigned, 不能用cin cout否则一定超时: 不能用abs(), abs 只用于整数. unsigned   ...

  2. printf scanf cin cout的区别与特征

    printf和scanf是c语言的输入输出,学习c++以后,自然是用cin cout这两个更简单的输入输出 printf scanf 都需要进行格式控制,比较麻烦,但优点是速度比较快,毕竟多做了一些事 ...

  3. C++输入输出流 cin/cout 及格式化输出简介

    C++ 可通过流的概念进行程序与外界环境( 用户.文件等 )之间的交互.流是一种将数据自源( source )推送至目的地( destination )的管道.在 C++ 中,与标准输入/输出相关的流 ...

  4. codeforces #446 892A Greed 892B Wrath 892C Pride 891B Gluttony

    A  链接:http://codeforces.com/problemset/problem/892/A 签到 #include <iostream> #include <algor ...

  5. cin,cout,printf,scanf效率对比

    From:http://www.cnblogs.com/killerlegend/p/3918452.html Author:KillerLegend Date:2014.8.17 杭电OJ之3233 ...

  6. scanf printf gets() puts(),cin cout

    最近在练机试题,常用的C和C++输入输出如下: 1 scanf 和printf int a; scanf("%d",&a) ; printf("%d", ...

  7. cin/cout与scanf/printf的比较

    转自http://www.cnblogs.com/penelope/articles/2426577.html  cin .cout   基本说明: cin是标准输入流对象,代表标准输入设备(键盘), ...

  8. cin cout getline string

    1.C++ code, When we want to read a number whatever the type is int or double , just use cin >> ...

  9. 关于cin 与 cout 的加速

    在用cin 与 cout 的时候 可以使用 ios::sync_with_stdio(); cin.tie(); cout.tie(); 这样在输入大数据的时候可以加快许多

随机推荐

  1. 2019 年 Google 编程之夏活动报告

    2019 年 Google 编程之夏活动报告 主要介绍了 GSoC 2019 活动的几个课题并讲述了整个活动的组织过程 Google 编程之夏活动不仅仅是一个夏日的实习项目,对于组织和一些社区的成员来 ...

  2. mysql 中两个日期相减获得 天 小时 分钟 或者 小时:分钟的格式

    /**有一个需求,要求获得两个日期想减的天数,小时数,分钟数.通过查找资料,于是乎我写出了如下代码,来获得两个字段.*/ IFNULL(CONCAT( ,'-',''), ),),'天')), ),) ...

  3. centos7-DNS(主从)

    一.安装DNS. 本机ip:192.168.1.3 [root@localhost ~]# yum -y install bind bind-utlis 二.编辑配置文件. [root@localho ...

  4. Linux-课后练习(第二章命令)20200217-1

  5. POJ 1731:Orders

    Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9940   Accepted: 6048 Descriptio ...

  6. convolution in frequency domain

    https://blog.csdn.net/myjiayan/article/details/72427995 convolution in frequency domain convolution ...

  7. sort()函数使用详解

    使用时需要导入头文件<algorithm> #include<algorithm> 语法描述:sort(begin,end,cmp),cmp参数可以没有,如果没有默认非降序排序 ...

  8. 记录 TypeError: render() got an unexpected keyword argument 'renderer' 错误

    在网上看到MXShop这个项目,适合Python, Django + drf 进阶的,其中遇到 TypeError: render() got an unexpected keyword argume ...

  9. 简单模拟B1001

    #include<iostream> using namespace std; int main() { int n; ; cin >> n; ) { == ) { n = ( ...

  10. Mybatis之二级缓存(八)

    1. 介绍 Mybatis缓存分为一级缓存和二级缓存,在本节中我们介绍下二级缓存的使用及其特性 MyBatis的一级缓存是在一个Session域内有效的,当Session关闭后,缓存内容也随之销毁.但 ...