题目
以下是我的代码在以上的数据范围会TLE,有没有dalao能在这代码的基础上改一改,使它能通过(悬4关
#include<iostream>
#include<queue>
#include<set>
using namespace std;
multiset<int> s;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
s.clear();
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
int o=m,cnt=0;
o-=x;
for(int x:s)
{
o-=x;
if(o<0)
{
break;
}
cnt++;
}
cout<<s.size()-cnt<<" ";
s.insert(x);
}
cout<<endl;
}
}