fork(1) download
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. typedef vector<unsigned> row;
  7.  
  8. int main()
  9. {
  10. unsigned W,H,N;
  11. cin>>W>>H>>N;
  12. vector<row> tb(H,row(W));
  13. while(N--)
  14. {
  15. unsigned w,h,z,sx,sy,zmax=0;
  16. cin>>w>>h>>z>>sx>>sy;
  17. w+=sx;
  18. h+=sy;
  19. for(unsigned y=sy;y<h;++y) for(unsigned x=sx;x<w;++x) zmax=max(zmax,tb[y][x]);
  20. zmax+=z;
  21. for(unsigned y=sy;y<h;++y) for(unsigned x=sx;x<w;++x) tb[y][x]=zmax;
  22. }
  23. unsigned zmax=0;
  24. for(unsigned y=0;y<H;++y) for(unsigned x=0;x<W;++x) zmax=max(zmax,tb[y][x]);
  25. cout<<zmax<<endl;
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 3464KB
stdin
7 5 4
4 3 2 0 0
3 3 1 3 0
7 1 2 0 3
2 3 3 2 2
stdout
6