从去年12月一直到现在调吐了都是92
/oh/oh/oh
by IAWNA @ 2023-04-03 22:06:05
@[IAWNA](/user/566878) 这题我过了,但我看不出来你哪错了/hsh
by hanyuchen2019 @ 2023-04-03 22:21:11
首先,不知道为什么你要在 ```t=t+a[i].a-a[i-1].a+a[i].b-1;``` 这里```-1```
其次,
```
q.push(a[i]);
if(t>m&&!q.empty())t-=q.top().b,nans--,q.pop();
//if(t>m)break;
```
改成
```
q.push(a[i].b);
while(t>m&&!q.empty()) t-=q.top(),nans--,q.pop();
if(t>m) break;
```
最后,估计很难看出来,把 ```priority_queue<N,std::vector<N>,std::less<N> >``` 改成 ```priority_queue<int>```,我也不知道为什么这里错了,有时间再看一下
# AC代码
```cpp
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define int long long
class N{
public:
#define int long long
int a,b;
inline bool operator <(const N &x)const{
return a<x.a;
}
inline bool operator >(const N &x)const{
return b>x.b;
}
}a[100005];
std::priority_queue<int>q;
signed main()
{
int n,m;
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;++i)
scanf("%lld%lld",&a[i].a,&a[i].b);
std::sort(a+1,a+n+1);
int t=0,ans=0,nans=0;
for(int i=1;i<=n;++i)
{
t=t+a[i].a-a[i-1].a+a[i].b;
nans++;
q.push(a[i].b);
while(t>m&&!q.empty()) t-=q.top(),nans--,q.pop();
if(t>m) break;
ans=std::max(nans,ans);
}
printf("%lld",ans);
}
```
by Sky_Maths @ 2023-09-29 17:36:09
[查明原因](https://www.luogu.com.cn/discuss/696313)
by Sky_Maths @ 2023-09-29 17:45:31