#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main() {
// Membaca input
int N;
cin >> N;
// Memvalidasi batasan N
if (N < 1 || N > 100) {
cerr << "Batasan N tidak terpenuhi." << endl;
return 1;
}
unordered_set<int> tidak_disukai;
for (int i = 0; i < N; ++i) {
int merk;
cin >> merk;
// Memvalidasi batasan Ai
if (merk < 1 || merk > 100) {
cerr << "Batasan Ai tidak terpenuhi." << endl;
return 1;
}
tidak_disukai.insert(merk);
}
int M;
cin >> M;
// Memvalidasi batasan M
if (M < 1 || M > 100) {
cerr << "Batasan M tidak terpenuhi." << endl;
return 1;
}
int jumlah_bingkisan_dapat_dibeli = 0;
for (int i = 0; i < M; ++i) {
int K;
cin >> K;
// Memvalidasi batasan Ki
if (K < 1 || K > 100) {
cerr << "Batasan Ki tidak terpenuhi." << endl;
return 1;
}
bool bingkisan_cocok = true;
for (int j = 0; j < K; ++j) {
int merk;
cin >> merk;
// Memvalidasi batasan Bi,j
if (merk < 1 || merk > 100) {
cerr << "Batasan Bi,j tidak terpenuhi." << endl;
return 1;
}
if (tidak_disukai.count(merk)) {
bingkisan_cocok = false;
}
}
if (bingkisan_cocok) {
jumlah_bingkisan_dapat_dibeli++;
}
}
// Menampilkan jumlah bingkisan yang dapat dibeli
cout << jumlah_bingkisan_dapat_dibeli << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
360 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |