Examples input 5 5 1 2 1 2 1 3 10 1 1 1 output 3 5 4 4 3 input 4 4 1 2 3 4 9 1 10 6 output 1 4 4 1 Note In the first example: after the 1-st minute, the 1-st and 2-nd warriors die. after the 2-nd minute all warriors die (and all arrows left over are…
题意: 有n个巫师站成一列,每个巫师有自己的血量. 一个人射箭攻击他们,每次造成若干点伤害,巫师按照给定的顺序承受伤害,如果伤害大了,那么死掉,伤害落到下一个巫师身上. 如果一轮攻击之后,所有的巫师都死了,那么他们会立即复活. 给出若干个询问,问每轮攻击之后还剩多少巫师活着. 思路: 前缀和加二分,每次伤害累加,大于了总和便归零且复活. 代码: #include <stdio.h> #include <string.h> #include <algorithm> usi…
C. Valhalla Siege time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave…
C. Valhalla Siege time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave…
http://codeforces.com/contest/702 题意:n个村庄,m个机站,问机站最短半径覆盖完所有村庄 思路:直接二分答案 二分太弱,调了半天..... // #pragma comment(linker, "/STACK:102c000000,102c000000") #include <iostream> #include <cstdio> #include <cstring> #include <sstream>…
A. Aramic script 题目大意:   对于每个单词,定义一种集合,这个集合包含且仅包含单词中出现的字母.给你一堆单词,问有多少种这种集合. 题解:   状压,插入set,取size #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <set> #include &…
A. Aramic script time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Aramic language words can only represent objects. Words in Aramic have special properties: A word is a root if it does no…
题目链接:http://codeforces.com/contest/975 A. Aramic script time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output In Aramic language words can only represent objects. Words in Aramic have special pro…
2018/5/6 Codeforces Round #478 (Div. 2) C http://codeforces.com/contest/975/problem/C Valhalla Siege 题意:n的士兵,每个士兵有一些生命值,有q次询问,每次询问从前向后造成ki点贯穿伤害(生命值归零的士兵死去,后续士兵承受溢出伤害),问每次询问有几个士兵还活着.当所有士兵死去时,不继续造成溢出伤害并且所有士兵复活. 思路:二分搜索,对士兵生命值求前缀和,每次询问造成的伤害累计,记为s,用upper…
原题链接:http://codeforces.com/problemset/problem/359/D 思路:首先对符合题目的长度(r-l)从0到n-1进行二分查找,对每一个长度进行check,看是否满足条件. 满足条件的话需要区间[l,r]内的最小值和最大公约数相等,如果暴力搜索,会超时,故采用st(sparse table)算法,建立table只需要O(nlgn)时间,查询是O(1),远远小于暴力搜索 st算法具体可参考http://baike.baidu.com/view/1536346.…