- //#include<iostream>
- //#include<vector>
- //#include<algorithm>
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- vector<int> building_size(N);//建築物的直線數
- vector<int> building_height(N);//建築物的高度
- int max_height = -1;
- for(int i=0; i<N; ++i)
- {
- cin >> building_size[i];
- int height = -1;
- int K = building_size[i];
- for(int j=0; j<K; ++j)
- {
- int s;
- cin >> s;
- height = max(height, s);//找建築物的高度
- }
- building_height[i] = height;
- if(height>max_height)
- max_height = height;//找出最高的建築物高度
- }
- long long ans = 0;//
- for(int i=0; i<N; ++i)
- {
- ans += (long long)building_size[i] * (max_height-building_height[i]);
- }
- cout << ans << endl;
- }
- /*
- 6
- 7 4 6 1 2 4 2 5
- 6 11 8 4 2 3 6
- 4 3 2 5 2
- 5 4 4 4 4 4
- 3 12 15 10
- 1 7
- */
複製代碼 |