Advertisement
a53

V_OF

a53
Apr 10th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3.  
  4. #define NMAX 1505
  5.  
  6. using namespace std;
  7.  
  8. ifstream f("v.in");
  9. ofstream g("v.out");
  10.  
  11. long long l1[NMAX], l2[NMAX], r1[NMAX], r2[NMAX];
  12. int main()
  13. {
  14. int n,m;
  15. f>>n>>m;
  16.  
  17. int maxi=-2000000009, cmax, lmax;
  18. for (int j = 1; j <= m; ++j)
  19. {
  20. f >> l1[j];
  21. r1[j] = l1[j];
  22. }
  23. for(int i=2; i<=n; ++i)
  24. {
  25.  
  26. for(int j=1; j<=m; ++j)
  27. {
  28. int x;
  29. f>>x;
  30. l2[j] = l1[j - 1] + x;
  31. r2[j] = r1[j + 1] + x;
  32.  
  33. if ( (j>=i) && (j<=m-i+1) && (l2[j] + r2[j] - x > maxi))
  34. {
  35. maxi = l2[j] + r2[j] - x;
  36. cmax = j - i + 1;
  37. lmax = i;
  38. }
  39. l1[j-1]=l2[j-1];
  40. r1[j-1]=r2[j-1];
  41. }
  42. l1[m]=l2[m];
  43. r1[m]=r2[m];
  44. /*memcpy(l1, l2, sizeof(l1));
  45. memcpy(r1, r2, sizeof(r1));*/
  46.  
  47. }
  48.  
  49. g<<maxi << ' ' << cmax << ' ' << lmax << '\n';
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement