fork(1) download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int scan(){int ip=getc(stdin),ret=0;for(;ip<'0'||ip>'9';ip=getc(stdin));for(;ip>='0'&&ip<='9';ip=getc(stdin))ret=ret*10+ip-'0';return ret;}
  4. int main(){
  5. int n ,q,r,s,t=0,u=0;
  6. char c[10];
  7. n=scan();
  8. q=scan();
  9. int *col=(int *)calloc(n,sizeof(int));
  10. int *row=(int *)calloc(n,sizeof(int));
  11. while(q--){
  12. scanf("%s",c); /* SOME ERROR HERE and how to use getchar_unlocked for char here*/
  13. r=scan();
  14. s=scan();
  15. if(c[0]=='R'){
  16. row[r-1]+=s;
  17. if(row[r-1]>u)
  18. u=row[r-1];
  19. }
  20. else {
  21. col[r-1]+=s;
  22. if(col[r-1]>t)
  23. t=col[r-1];
  24. }
  25. }
  26. printf("%d",t+u);
  27. free(row); free(col);
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 1968KB
stdin
2 4
RowAdd 1 3
ColAdd 2 1
ColAdd 1 4
RowAdd 2 1
stdout
7