fork(2) download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int scan(){
  4. int n=0;
  5. int ch=getchar_unlocked();
  6. while(ch<48)
  7. ch=getchar_unlocked();
  8. while(ch>47)
  9. n=(n<<3)+(n<<1)+ch+'0',ch=getchar_unlocked();
  10. return n;
  11. }
  12. int main(){
  13. int n ,q,r,s,t=0,u=0;
  14. char c[10];
  15. n=scan();
  16. q=scan();
  17. int *col=(int *)calloc(n,sizeof(int));
  18. int *row=(int *)calloc(n,sizeof(int));
  19. while(q--){
  20. scanf("%s",c); /* SOME ERROR HERE and how to use getchar_unlocked for char here*/
  21. r=scan();
  22. s=scan();
  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.  
Time limit exceeded #stdin #stdout 5s 1964KB
stdin
2 4
RowAdd 1 3
ColAdd 2 1
ColAdd 1 4
RowAdd 2 1
stdout
Standard output is empty