CodeForces892B Wrath
来源:互联网 发布:ubuntu优麒麟 编辑:程序博客网 时间:2024/06/09 23:17
题目链接:http://codeforces.com/problemset/problem/892/B
题意:对于一排人来说,如果存在i > j && j >= i - a[i],则i可以杀死j,一个人杀死其他人都是同时进行的,问最后会剩下几个人。
思路:每当输入一个a[i]时,便判断其与其前面的是否符合上面的条件,符合就下标减一,知道没有元素符合这个条件或者下标变成0
#include <bits/stdc++.h>using namespace std;int n,a[1100000];int main(){ scanf("%d",&n); int indx = 0,x; for(int i = 1; i <= n; i ++){ scanf("%d",&x); while(a[indx] && i - x <= a[indx]) indx --; a[++ indx] = i; } printf("%d\n",indx); return 0;}
阅读全文
0 0
- CodeForces892B Wrath
- Wrath CodeForces
- Codeforces 892B. Wrath
- CodeForces 892B Wrath
- codeforces-892B Wrath
- codeforces 892B. Wrath
- CodeForce 446 Div.2 Wrath
- B. Wrath (思路题目)
- The Wrath of Achilles (Episode 116)
- Codeforces 892 B. Wrath (递推)
- Codeforces Round #446 (Div. 2) B Wrath
- Codeforces Round #446 (Div. 2) B.Wrath
- Codeforces 892B Wrath 【差分】
- Codeforces 892B Wrath (递推)
- Codeforces Round #446 (Div. 2)B. Wrath
- 趣味题:杀人范围 codeforces B. Wrath
- Codeforces Round #446 (Div. 2) B. Wrath (贪心)
- Codeforces-446(Div.2)-B-Wrath--(线段树区间更新)
- mysql基础&重点知识总结及在python中的应用(2)
- C语言贪心算法之喷水装置(二)
- leetcode 372. Super Pow
- LOJ6000 「网络流 24 题
- Spring Bean生命周期
- CodeForces892B Wrath
- 程序员的8条宝贵经验!
- Golang简介
- HihoCoder
- 导航栏渐变方案收录二
- 如何快速获得自己的所有csdn博客地址
- LeetCode174. Dungeon Game
- Python 快速入门资料
- 数据结构实验之图论七:驴友计划