General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
268804778 Practice:
SkyStalker_2.0
1974G - 16 C++17 (GCC 7-32) Accepted 140 ms 4608 KB 2024-07-04 19:26:55 2024-07-04 19:26:55
→ Source
               /* “  Trying to fill the left void :)     ” */


#include<bits/stdc++.h>
using namespace std;


int M =  1e9 + 7;
int SM=1000005;
long long int LM=1e18;


#define ll long long int
#define endl '\n'
#define sp <<" "<<
#define S second
#define F first
#define dbg cout<<"hi"
const int MOD=1e9+7;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll arr[n];
        for(ll i=0;i<n;i++){
            cin>>arr[i];
        }
        multiset<ll>s;
        ll sum=k;
        for(ll i=1;i<n;i++){
            if(sum>=arr[i]){
                sum-=arr[i];
                s.insert(arr[i]);
            }
            else{
                if(s.size()>0 && *(--s.end())>arr[i]){
                    sum+=*(--s.end());
                    sum-=arr[i];
                    s.erase((--s.end()));
                    s.insert(arr[i]);
                }
            }
            sum+=k;
        }
        cout<<s.size()<<endl;
    }
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details