fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, q, r[314160], c[314160], max[314160], ans, b, d;
  8. char s[10];
  9. ans=0;
  10. memset(r, 0, sizeof(r));
  11. memset(c, 0, sizeof(c));
  12. memset(max, 0, sizeof(max));
  13. scanf("%d%d", &n, &q);
  14. for(int i=0; i<q; i++) {
  15. scanf("%s%d%d", s, &b, &d);
  16. if(s[0]=='R') c[b-1]+=d;
  17. else r[b-1]+=d;
  18. }
  19. for(int i=0; i<n; i++) for(int j=0; j<n; j++) if(r[i]+c[j]>max[i]) {
  20. max[i]=r[i]+c[j];
  21. if(max[i]>ans) ans=max[i];
  22. }
  23. printf("%d", ans);
  24. return 0;
  25. }
Success #stdin #stdout 0s 6900KB
stdin
2 4
RowAdd 1 3
ColAdd 2 1
ColAdd 1 4
RowAdd 2 1
stdout
7