Atcoder Beginner Contest153F(模拟)
应该也可以用线段树/树状数组区间更新怪兽的生命值来做
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
long long pre[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,d,a;
cin>>n>>d>>a;
vector<pair<long long,long long> >v;
for(int i=;i<=n;++i){
long long x,y;
cin>>x>>y;
long long z=(y-)/a+;
v.push_back({x,z});
}
sort(v.begin(),v.end());
long long ans=;
long long sum=;
int r=;//打不到的最近范围
for(int i=;i<n;++i){
while(r<n&&v[r].first<=v[i].first+*d)
++r;
sum-=pre[i];//sum为当前位置已经预先承受的伤害总量
v[i].second-=sum;
if(v[i].second<=)
continue;
sum+=v[i].second;//累计伤害
pre[r]+=v[i].second;//r位置以前承受的伤害总量
ans+=v[i].second;
}
cout<<ans;
return ;
}
Atcoder Beginner Contest153F(模拟)的更多相关文章
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 064 D - Insertion
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...
- AtCoder Beginner Contest 177 题解
AtCoder Beginner Contest 177 题解 目录 AtCoder Beginner Contest 177 题解 A - Don't be late B - Substring C ...
- AtCoder Beginner Contest 161
比赛链接:https://atcoder.jp/contests/abc161/tasks AtCoder Beginner Contest 161 第一次打AtCoder的比赛,因为是日本的网站终于 ...
- AtCoder Beginner Contest 223
AtCoder Beginner Contest 223 A是纯纯的水题,就不说了 B - String Shifting 思路分析 我真的sb,一开始想了好久是不是和全排列有关,然后读了好几遍题目也 ...
- AtCoder Beginner Contest 184 题解
AtCoder Beginner Contest 184 题解 目录 AtCoder Beginner Contest 184 题解 A - Determinant B - Quizzes C - S ...
- AtCoder Beginner Contest 148 题解
目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...
- AtCoder Beginner Contest 238 A - F 题解
AtCoder Beginner Contest 238 \(A - F\) 题解 A - Exponential or Quadratic 题意 判断 \(2^n > n^2\)是否成立? S ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
随机推荐
- 【分享】一款特别轻量的gif生成工具
github链接:https://github.com/NickeManarin/ScreenToGif/releases/tag/2.19.3 超级好用!支持多种方式(摄像头也可√)录制gif
- php Allowed memory size of 134217728 bytes exhausted
报错:PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in ...
- 剖析Javascript中forEach()底层原理,如何重写forEach()
我们平时用的forEach()一般是这样用的 var myArr = [1,5,8] myArr.forEach((v,i)=>{ console.log(v,i) })//运行后是这样的1 0 ...
- SpringBoot学习- 5、整合Redis
SpringBoot学习足迹 SpringBoot项目中访问Redis主要有两种方式:JedisPool和RedisTemplate,本文使用JedisPool 1.pom.xml添加dependen ...
- AntDesign(React)学习-11 使用mobx
mobx 是由 Mendix.Coinbase.Facebook 开源和众多个人赞助商所赞助的. mobx和redux类似,也可以用来进行状态管理,并且更简单,更灵活.初次研究,先实现一个最简单的功能 ...
- Oracle登录报错-ORA-00119
报错 如果配置监听没有问题了,但是连接时又出现ORA-00119问题: ORA-00119: invalid specification for system parameter LOCAL_LIST ...
- HTML span标签
span:行内标签,不会换行用于:组合文档中的行内元素.元素和文档的组合
- C 库函数 - strncpy()
描述 C 库函数 char *strncpy(char *dest, const char *src, size_t n) 把 src 所指向的字符串复制到 dest,最多复制 n 个字符.当 src ...
- Postman:下载安装与基本介绍
1.下载: (1)官网APP: https://www.getpostman.com/ (即: https://app.getpostman.com/app/download/win64 ) (2)插 ...
- 使用pip install mysqlclient命令安装mysqlclient失败?(基于Python)
我们使用Django.flask等来操作MySQL,实际上底层还是通过Python来操作的.因此我们想要用Django来操作MySQL,首先还是需要安装一个驱动程序.在Python3中,驱动程序有多种 ...