链接

[https://codeforces.com/contest/1141/problem/E]

题意

怪物开始的生命值,然后第i分钟生命值的变化

问什么时候怪物生命值为非正

分析

有一个巨大的坑

其实是很简单的一个题

可我还是跳了进去很多次

对于超过n的特别注意就行了

算是经典贪心吧

看代码吧

代码

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+10;
ll d[N];
ll sum;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0); int n;
ll H;
//freopen("in.txt","r",stdin);
while(cin>>H>>n){
sum=0;
ll cur=H,mi=1e17;
bool flag=0;
ll ans;
for(int i=1;i<=n;i++)
{
cin>>d[i]; sum+=d[i];
mi=min(mi,sum);
H+=d[i];
if(!flag&&H<=0) {
ans=i; flag=1;
}
}
if(flag){
cout<<ans<<endl;
}
else if(sum>=0){
cout<<-1<<endl;
}
else{
cur+=mi;
ans=(cur)/(-sum)*n;
ll mo=cur%(-sum);
ll k=mo-mi;
ll cnt=0;
while(k>0){
for(int i=1;i<=n;i++)
{
k+=d[i];
cnt++;
if(k<=0) break;
}
}
//cout<<ans<<' '<<cnt<<endl;
cout<<ans+cnt<<endl;
}
}
return 0;
}

E. Superhero Battle的更多相关文章

  1. E. Superhero Battle Codeforces Round #547 (Div. 3) 思维题

    E. Superhero Battle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #547 (Div. 3) E. Superhero Battle

    E. Superhero Battle A superhero fights with a monster. The battle consists of rounds, each of which ...

  3. CF1141E Superhero Battle

    A superhero fights with a monster. The battle consists of rounds, each of which lasts exactly n minu ...

  4. Codeforces1141E(E题)Superhero Battle

    A superhero fights with a monster. The battle consists of rounds, each of which lasts exactly nn min ...

  5. 【CF1141E】Superhero Battle

    \[x*p\ge y\rightarrow x=\lfloor{{y-1}\over p}\rfloor+1\]

  6. 【Codeforces 1141E】Superhero Battle

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 二分最后轮了几圈. 二分之后直接o(N)枚举具体要多少时间即可. 注意爆long long的情况. 可以用对数函数,算出来有多少个0 如果大于 ...

  7. Codeforces Round #547 (Div. 3) E. Superhero Battle (数学)

    题意:有一个HP为\(h\)的大怪兽,你需要轮流进行\(i\)次操作.每次可以使\(h+=d_i\)(\(d_i\)有正有负),当第\(n\)次操作完成后,再从第一次开始,问能否使得怪兽的HP变为\( ...

  8. Codeforces Round #547 (Div. 3) 题解

    Codeforces Round #547 (Div. 3) 题目链接:https://codeforces.com/contest/1141 A,B咕咕了... C. Polycarp Restor ...

  9. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

随机推荐

  1. win7 中 sql server2005 卸载简介

    注:卸载前一定要做好备份,一定要清理干净,不然重装会出错(只针对完全卸载,没试过只删除一个版本的) 工具:①Windows Install Clean Up  ②SrvInstw.exe 1.停止所有 ...

  2. c/c++ 多态的实现原理分析

    多态的实现原理分析 当类里有一个函数被声明成虚函数后,创建这个类的对象的时候,就会自动加入一个__vfptr的指针, __vfptr维护虚函数列表.如果有三个虚函数,则__vfptr指向的是第一个虚函 ...

  3. c/c++拷贝构造函数和关键字explicit

    c/c++拷贝构造函数和关键字explicit 关键字explicit 修饰构造方法的关键字,加上了,就告诉编译器,不可以隐式初始化对象:不加就可以隐式初始化对象: 下面的代码是可以正常编译执行的,但 ...

  4. powershell脚本之windows服务与进程

    powershell脚本之windows服务与进程 服务与进程的区别: Windows服务是指系统自动完成的,不需要和用户交互的过程,可长时间运行的可执行应用程序 进程是程序运行的实例,系统会给运行中 ...

  5. February 21st, 2018 Week 8th Wednesday

    Our life is what our thoughts make it. 我们的思想成就了我们的生活. The mind is everything. What you think, you be ...

  6. 【Beta】博客合集

    [Beta Scrum]冲刺! 1/5 [Beta Scrum]冲刺! 2/5 [Beta Scrum]冲刺! 3/5 [Beta Scrum]冲刺! 4/5 [Beta Scrum]冲刺! 5/5

  7. 【Teradata】 TPT基础知识

     1.TPT Description Teradata Parallel Transporter (TPT) is client software that performs data extract ...

  8. ubuntu使用遇到的问题

    1.不适当操作,改了sudoers的权限 scdev@scdev1005:~$ sudo vim /etc/profilesudo: /etc/sudoers is owned by uid 1000 ...

  9. (转)Spring Boot(六):如何优雅的使用 Mybatis

    http://www.ityouknow.com/springboot/2016/11/06/spring-boot-mybatis.html 这两天启动了一个新项目因为项目组成员一直都使用的是 My ...

  10. stroop效应matlab实验

    1 打开matlab,打开test1.m 点击运行,若出现选择 更改文件夹 2  引导界面 (在这个界面,只许用户鼠标点击开始,其余的别乱按按键. 记得将打字法关掉,切换到小写) 3 做题界面 根据颜 ...