Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define smin(X, Y) ((X) < (Y) ? (X) : (Y))
- int w, h, mx, dif;
- unordered_map <int, int> m;
- int main()
- {
- ifstream cin ("zzid.in");
- ofstream cout ("zzid.out");
- cin >> h >> w;
- for (int i=1, nr, x = 0; i<=h; i++, x = 0)
- {
- cin >> nr;
- for (int j=1, l; j<=nr; j++)
- {
- cin >> l;
- if (j == nr) continue;
- x += l; m[x]++;
- if (m[x] > mx) mx = m[x], dif = abs(x - (w - x));
- else if (m[x] == mx) dif = smin(dif, abs(x - (w - x)));
- }
- }
- cout << (h - mx) << ' ' << dif;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement