@[_ZZH](/space/show?uid=27398) @星空煌 @默思·朸安 @[Yeasion_Nein](/space/show?uid=60528) @[Lance1ot](/space/show?uid=28007) @[SOLDIER_76](/space/show?uid=34586) @[Misaka_Azusa](/space/show?uid=28084) @_rqy
@皎月半洒花
by 青珹 @ 2018-06-03 19:25:53
@[默思·朸安](/space/show?uid=34188) @[_rqy](/space/show?uid=7868)
by 青珹 @ 2018-06-03 19:26:27
@[皎月半洒花](/space/show?uid=28313) @[苑骏康](/space/show?uid=39157)
by 青珹 @ 2018-06-03 19:27:25
@[邱城锐大神](/space/show?uid=31980) 下载个数据本地试试?
by 引领天下 @ 2018-06-03 19:36:25
@[引领天下](/space/show?uid=39863) 没数据可下……他不支持……
by 青珹 @ 2018-06-03 19:40:29
# $\mathfrak{WA}$~~~~
> $TQL$
by Lance1ot @ 2018-06-03 19:42:15
@[邱城锐大神](/space/show?uid=31980) \手动滑稽
by 引领天下 @ 2018-06-03 20:11:54
%%%%%%%%%%%%%
by Sue_Shallow @ 2018-06-03 20:16:48
1.数据范围看错了
2.数组再开大一点
3.思路没有问题(没注释很难受啊,我看了好半天)
4.按照上面所说的我从你的板子上改了改,就A了
AC代码:
```cpp
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
long long int n,m,wjs,ans,foot;
struct qaq{
long long int road;
long long int t;
}e[300002];
struct qwq{//大根堆
qaq heap[300002];
int num;
void _in(qaq p){
heap[++num]=p;
int now=num;
while(now>1){
if(heap[now].t>heap[now>>1].t){
swap(heap[now],heap[now>>1]);
now>>=1;
}
else
break ;
}
return ;
}
void _del(){
swap(heap[num--],heap[1]);
int now=1;
int tt;
while(now<num){
tt=now;
if(heap[tt].t<heap[now<<1].t&&(now<<1)<=num)
tt=now<<1;
if(heap[tt].t<heap[now<<1|1].t&&(now<<1|1)<=num)
tt=now<<1|1;
if(tt==now)
break ;
swap(heap[tt],heap[now]);
now=tt;
}
return ;
}
long long int head(){
return heap[1].t;
}
};qwq hb;
bool cmp(const qaq &x,const qaq &y){
return x.road<y.road;
}
int main(){
scanf("%lld%lld",&n,&m);
int top=0;
for(int i=1;i<=n;i++){
long long int x,y;
scanf("%lld%lld",&x,&y);
if(x+y>m)
continue ;
e[++top].road=x;
e[top].t=y;
}
n=top;
sort(e+1,e+n+1,cmp);
top=1;
while(top<=n){
if(e[top].road-foot>m){
if(hb.num==0)
break ;
else{
while(hb.num>0&&e[top].road-foot>m){
m+=hb.head();
hb._del();
wjs--;
}
}
if(e[top].road-foot>m)
break ;
}
m-=(e[top].road-foot);
foot=e[top].road;
if(e[top].t<=m){
m-=e[top].t;
hb._in(e[top]);
wjs++;
ans=max(ans,wjs);
}
else{
long long int k=hb.head();
if(k<e[top].t){
top++;
continue ;
}
else{
if(hb.num==0)
break ;
else{
m+=k;
hb._del();
m-=e[top].t;
hb._in(e[top]);
}
}
}
top++;
}
printf("%lld",ans);
return 0;
}
```
祝你好运
by _ZZH @ 2018-06-03 20:21:22
@[_ZZH](/space/show?uid=27398) 感激不尽!这道题我看了三天了……好人啊!
by 青珹 @ 2018-06-03 20:23:49