➤ Problem Link : PRO
👉 Hint : edit please
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; int main() { int n,k,x; long long int ans=0; cin>>n; multiset<int>m; for(int i=1;i<=n;i++) { cin>>k; for(int j=1;j<=k;j++) { cin>>x; m.insert(x); } int l=*(m.begin()); int h=*(--m.end()); ans+=h-l; m.erase(m.begin()); m.erase(--m.end()); } cout<<ans<<endl; }
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!