This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin>>n;
int d[n], cnt[n];
for (int i = 0; i < n; i++)
cnt[i] = 0;
int e = 0;
for (int i = 0; i < n; i++) {
cin >> d[i]; cnt[d[i]]++;
e += d[i];
int x;
for (int j = 0; j < d[i]; j++)
cin>>x;
}
sort(d, d+n, greater<int>());
int x = 0, ans = 0;
for (int k = 0; k < n-1; k++) {
x += d[k];
if (2*x == k*(k+1) + e) {
if (d[k] == d[k+1]) ans += cnt[d[k]];
else ans++;
}
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |