Doubt in charge scheduling problem from augustlongchallenge2021

I am not able to understand this part
auto it=–d.end();
sum+=a[i]-it->first;
check[it->second]=false;
d.erase(it);
in below code

#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t–){
int n;cin>>n;
vector a(n),b(n),index(n),check(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
fill(check.begin(),check.end(),0);
iota(index.begin(),index.end(),0);
sort(index.begin(),index.end(),[&b](int u,int v){return b[u]<b[v];});
int sz=0,sum=0;
multiset<pair<int,int>> d;
for(auto i:index){
d.insert(make_pair(a[i],i));
check[i]=true;
if(sum+a[i]>b[i]){
auto it=–d.end();
sum+=a[i]-it->first;
check[it->second]=false;
d.erase(it);
}else {
sum+=a[i];
sz++;
}
}
cout<<sz<<endl;sum=0;
for(int i:index){
if(check[i]){
cout<<i+1<<" “<<sum<<” "<<sum+a[i]<<endl;
sum+=a[i];
}
}
}
}

Comment down on the editorial thread instead of creating a new one.