题目出处: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. JS下拉框联动

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. Swift实现iOS录音与播放音频功能

    作用AVPLayer:可以用来播放在线及本地音视频AVAudioSession:音频会话,主要用来管理音频设置与硬件交互使用时需要导入 #import <AVFoundation/AVFound ...

  3. Failed to connect to raw.githubusercontent.com port 443: Connection refused

    问题:macOS安装Homebrew时总是报错(Failed to connect to raw.githubusercontent.com port 443: Connection refused) ...

  4. maven的理解和使用

    一.maven是什么? maven是项目管理工具 二.maven为什么要用? 在做开发的时候常常会用到外部的工具包(jar包),这就需要你一个一个的去他们的官网下工具包,然后在项目里依赖他们,比较的麻 ...

  5. <style scoped >中使用深度选择器影响子组件

    摘自:https://blog.csdn.net/zhouzuoluo/article/details/95593143 <style scoped >中使用深度选择器影响子组件 在< ...

  6. 吴裕雄--天生自然TensorFlow2教程:合并与分割

    import tensorflow as tf # 6个班级的学生分数情况 a = tf.ones([4, 35, 8]) b = tf.ones([2, 35, 8]) c = tf.concat( ...

  7. 微服务之docker(一)

    一.docker介绍及使用 1.docker简介 (1)Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器或Windo ...

  8. 开源PLM软件Aras详解八 Aras之RelationshipTypes关系类详解

    在Aras中,在之前ItemType解析中有提到,Aras中实际ItemType对应的就是一张表,那么,ItemType与ItemType之间是如何关联的呢, 如果我们需要捋清楚ItemType与It ...

  9. [SWPU2019]Web1

    0x00 知识点 bypass information_schema 参考链接: https://www.anquanke.com/post/id/193512 进行bypass之前先了解一下mysq ...

  10. HashMap看这篇就够了

    HashMap看这篇就够了 一文读懂HashMap Java8容器源码-目录