fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int N,d,v,j[101]={},t[101]={};
  5. cin>>N;
  6. while(N--){cin>>d>>v; j[d]++; t[d]+=v;}
  7. for(int i=1;i<=100;i++) if(j[i])
  8. cout<<"Desa "<<i<<": "<<j[i]<<" pendonor, total "<<t[i]<<" ml\n";
  9. }
Success #stdin #stdout 0.01s 5316KB
stdin
8 
3
3 1 150
1 2 250 
3 1 300
1 3 450
2 2 200
3 4 350
14500
21500
stdout
Desa 1: 4 pendonor, total 455 ml
Desa 2: 1 pendonor, total 200 ml
Desa 3: 1 pendonor, total 3 ml