fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4. #define double long double
  5. #define print(a) for(auto x : a) cout << x << " "; cout << endl
  6.  
  7.  
  8. const int M = 1000000007;
  9. const int N = 3e5+9;
  10. const int INF = 2e9+1;
  11. const int LINF = 2000000000000000001;
  12.  
  13. inline int power(int a, int b, int mod=M) {
  14. int x = 1;
  15. a %= mod;
  16. while (b) {
  17. if (b & 1) x = (x * a) % mod;
  18. a = (a * a) % mod;
  19. b >>= 1;
  20. }
  21. return x;
  22. }
  23.  
  24.  
  25. //_ ***************************** START Below *******************************
  26.  
  27. // 6
  28. // 4
  29. // 1 2 2 1
  30. // 3
  31. // 3 1 2
  32. // 3
  33. // 1 3 2
  34. // 2
  35. // 2 4
  36. // 3
  37. // 3 1 2
  38. // 4
  39. // 1 3 1 1
  40.  
  41.  
  42. vector<vector<int>> a;
  43.  
  44. int consistency(int n){
  45.  
  46. unordered_map<long long,int> mp;
  47.  
  48. for(int i=0; i<n; i++){
  49. long long sum = 0;
  50. for(int j=0; j<a[i].size()-1; j++){
  51. sum += a[i][j];
  52. mp[sum]++;
  53. }
  54. }
  55.  
  56. int maxi = 0;
  57. for(auto& p : mp){
  58. maxi = max(maxi, p.second);
  59. }
  60.  
  61. return n-maxi;
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. int practice(int n){
  79.  
  80.  
  81. return 0;
  82. }
  83.  
  84.  
  85.  
  86.  
  87.  
  88. void solve() {
  89.  
  90. int n;
  91. cin>> n;
  92.  
  93. for(int i=0; i<n; i++){
  94. int m;
  95. cin >> m;
  96. vector<int> tp(m);
  97. for(int j=0; j<m; j++) cin >> tp[j];
  98.  
  99. a.push_back(tp);
  100. }
  101.  
  102. cout << consistency(n) << endl;
  103.  
  104.  
  105. }
  106.  
  107.  
  108.  
  109.  
  110.  
  111. int32_t main() {
  112. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  113.  
  114. int t = 1;
  115. // cin >> t;
  116. while (t--) {
  117. solve();
  118. }
  119.  
  120. return 0;
  121. }
Success #stdin #stdout 0.01s 5284KB
stdin
6
4
1 2 2 1
3 
3 1 2
3 
1 3 2
2
2 4
3
3 1 2
4
1 3 1 1
stdout
2