a53

matop

a53
Oct 4th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream f("matop.in");
  4. ofstream g("matop.out");
  5. int n,k,op,lin,col,val;
  6. int a[25001],b[25001],d[25001];
  7. int s;
  8.  
  9. int main()
  10. {
  11. f>>n>>k;
  12. for(int i=1;i<=k;++i)
  13. {
  14. f>>op;
  15. if(op==1)
  16. {
  17. f>>lin>>val;
  18. if(a[lin]<val)
  19. {
  20. if(d[lin]<val)
  21. s+=(val-d[lin]),d[lin]=val;
  22. a[lin]=val;
  23. }
  24. }
  25. if(op==2)
  26. {
  27. f>>col>>val;
  28. if(b[col]<val)
  29. {
  30. if(d[col]<val)
  31. s+=(val-d[col]),d[col]=val;
  32. b[col]=val;
  33. }
  34. }
  35. if(op==3)
  36. {
  37. f>>lin>>col;
  38. g<<max(a[lin],b[col])<<'\n';
  39. }
  40. if(op==4)
  41. {
  42. g<<s<<'\n';
  43. }
  44. }
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment