Poj Solution 1761

http://poj.org/problem?id=1761

#include<iostream>
#include"string.h"
#include"stdio.h"
using namespace std;
char name[62][10],w[10];
long ci[62][9],ti[62][9];
int main()
{long i,n,j,m,t,c;char q,a;
    for(i=0;i<62;i++)
    for(j=0;j<9;j++){ti[i][j]=-1;ci[i][j]=0;}
cin>>n;
m=0;
while(n--)
{cin>>t>>w>>q>>a;
for(i=0;i<m;i++)if(strcmp(name[i],w)==0)break;
if(i==m){m++;strcpy(name[m-1],w);}

j=q-'A';
if(ti[i][j]==-1){ci[i][j]++;if(a=='A')ti[i][j]=t;}
}

int ac;
for(j=0;j<9;j++)
{c=0;t=0;ac=0;
for(i=0;i<62;i++)
if(ti[i][j]!=-1){ac++;c+=ci[i][j];t+=ti[i][j];}
printf("%c %ld",j+'A',ac);
if(ac)printf(" %.2f %.2f",(float)c/ac,(float)t/ac);
printf("n");
}
return 0;
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *