Advertisement
a53

Zzid

a53
May 19th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define smin(X, Y) ((X) < (Y) ? (X) : (Y))
  4. int w, h, mx, dif;
  5. unordered_map <int, int> m;
  6.  
  7. int main()
  8. {
  9. ifstream cin ("zzid.in");
  10. ofstream cout ("zzid.out");
  11. cin >> h >> w;
  12. for (int i=1, nr, x = 0; i<=h; i++, x = 0)
  13. {
  14. cin >> nr;
  15. for (int j=1, l; j<=nr; j++)
  16. {
  17. cin >> l;
  18. if (j == nr) continue;
  19. x += l; m[x]++;
  20. if (m[x] > mx) mx = m[x], dif = abs(x - (w - x));
  21. else if (m[x] == mx) dif = smin(dif, abs(x - (w - x)));
  22. }
  23. }
  24. cout << (h - mx) << ' ' << dif;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement