#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
648 KB |
Output is correct |
2 |
Correct |
58 ms |
3072 KB |
Output is correct |
3 |
Correct |
263 ms |
13388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
760 KB |
Output is correct |
2 |
Correct |
77 ms |
4120 KB |
Output is correct |
3 |
Correct |
349 ms |
18092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
3068 KB |
Output is correct |
2 |
Correct |
172 ms |
9080 KB |
Output is correct |
3 |
Correct |
579 ms |
29688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
5112 KB |
Output is correct |
2 |
Correct |
396 ms |
21056 KB |
Output is correct |
3 |
Correct |
1335 ms |
69544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
904 ms |
47952 KB |
Output is correct |
2 |
Correct |
596 ms |
31272 KB |
Output is correct |
3 |
Correct |
2040 ms |
107728 KB |
Output is correct |
4 |
Correct |
2227 ms |
111816 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |