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 ...
随机推荐
- 2.Ubuntu安装 Docker
平台支持 Docker CE 支持多种平台,如下表所示 桌面 平台 架构 Docker Desktop for Mac (macOS) X64 Docker Desktop for Windows ( ...
- 本地项目如何上传到github
首先登录官网注册用户(此处不多介绍),然后需要登录github创建仓库 https://github.com/ 然后取一个自己喜欢的名字(这里我的名字是webclock),点击Create rep ...
- Codeforces Round #621 (Div. 1 + Div. 2)D(最短路,图)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; vector<]; ]; ] ...
- Xampp在Mac下报403的问题
将httpd.conf里的 User daemonGroup daemon 改为 User myusername(当前使用的用户名)Group admin
- Unable to connect to a repository at URL
缓存问题: 1. 右键点击本地副本,TortoiseSVN -> Settings -> Saved Data, 2.点击“Clear”按钮,把本地缓存都清除了,点击“确定”: 3. 再重 ...
- 第一次刷leetcode小结
LeetCode 上不会的 Reverse Integer Gray Code Generate Parentheses Pascal's Triangle II 正方向读和反方向读保持不变的区别 T ...
- 使用tableExport.js直接导出web页面上的table
1,需要导入两个js文件,一个tableExport.js,另一个是jquery.base64.js,前一个文件是导出数据和核心类库,后一个是为了避免导出中文时乱码的js文件,如果你导出的数据没有中文 ...
- c数据结构 -- 链表的理解
链表是结构体变量与结构体变量链接在一起,怎么链接在一起?通过指针 #include <stdio.h> struct Node{ int data; struct Node* next; ...
- layout components pages及基本操作
components组件 layouts模板 pages nuxt.config.js nuxt的配置文件
- 题解 【Codeforces381A】 Sereja and Dima
本题是很好的双指针练习题. 关于双指针,详见洛谷日报#73. 我们可以用两个指针l和r表示题中两人接下来要比较的数字,用fl标记下一个将要取的人,并分别用两个计数器统计双方的答案. 因此,我们有了如下 ...