fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N, M;
  6. cin >> N >> M; // jumlah DDS dan jumlah desa
  7.  
  8. int pendonor[100] = {0}; // array desa, cukup untuk 100 desa
  9.  
  10. for (int i = 0; i < N; i++) {
  11. int kodeDesa, golDarah, volume;
  12. cin >> kodeDesa >> golDarah >> volume;
  13.  
  14. // Hitung semua DDS, tidak peduli volume
  15. if (kodeDesa >= 1 && kodeDesa <= M) {
  16. pendonor[kodeDesa - 1]++;
  17. }
  18. }
  19.  
  20. // Cetak jumlah pendonor tiap desa
  21. for (int i = 0; i < M; i++) {
  22. cout << "Desa " << (i + 1) << ": " << pendonor[i] << endl;
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty