Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define ff first
- #define ss second
- #define pb push_back
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- _test
- {
- int n;
- cin>>n;
- vector<int> a;
- vector<int> b;
- int mmin = 1e9;
- for(int i=0; i<n; i++)
- {
- int k;
- cin>>k;
- b.resize(k);
- for(auto &e: b) cin>>e;
- sort(b.begin(), b.end());
- mmin = min(mmin, b[0]);
- a.pb(b[1]);
- }
- sort(a.begin(), a.end());
- a[0] = mmin;
- cout<<accumulate(a.begin(), a.end(), 0ll)<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment