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