簡單的潛力題
#include <bits/stdc++.h>
#define fast_as_a_fuckboy ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
fast_as_a_fuckboy;
int n;
cin >> n;
vector<vector<long long int>> a(n);
vector<long long int> k(n);
vector<long long int> mx(n, INT_MIN);
long long int ans = 0;
long long int now = INT_MIN;
for (int i = 0; i < n; i++) {
cin >> k[i];
a[i].resize(k[i]);
for (int j = 0; j < k[i]; j++) {
cin >> a[i][j];
mx[i] = max(mx[i], a[i][j]);
}
now = max(now, mx[i]);
}
for(int i = 0;i < n;i++) {
ans += (now - mx[i]) * k[i];
}
cout << ans << "\n";
}