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