Advertisement
a53

culori4

a53
Feb 9th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. //prof. Lucia Miron
  2. #include <fstream>
  3. #include <cassert>
  4.  
  5. using namespace std;
  6. ifstream fin("culori.in");
  7. ofstream fout("culori.out");
  8. int cc,n,m,c[20001], i, j, lg, lgmax,cer,a,b,x;
  9. int v1[20001];
  10.  
  11. int main()
  12. {
  13. fin>>cer;
  14. assert(cer == 1 || cer == 2);
  15. fin>>cc>>n>>m;
  16. assert(cc > 0 && cc < 1000001);
  17. assert(n > 0 && n < 10001);
  18. assert(m > 0 && m < 200001);
  19. for(i=1; i<=n; i++)
  20. {
  21. fin>>c[i];
  22. assert(c[i] > 0 && c[i] <= cc);
  23. }
  24. if(cer==1)
  25. {
  26. lg=1;
  27. for(i=2; i<=n; i++)
  28. if(c[i]==c[i-1])lg++;
  29. else
  30. {
  31. if(lg>lgmax)lgmax=lg;
  32. lg=1;
  33. }
  34. if(lg>lgmax)lgmax=lg;
  35. fout<<lgmax<<endl;
  36. }
  37. else
  38. {
  39. for(i=1; i<=m; i++)
  40. {
  41. fin>>a>>b>>x;
  42. assert(a > 0 && a < n);
  43. assert(b >= a && b <= n);
  44. v1[a]+=x;
  45. v1[b+1]+=-x;
  46. }
  47. for(i=1; i<=n; i++)
  48. v1[i]=v1[i-1]+v1[i];
  49. for(i=1; i<=n; i++)
  50. {
  51. c[i]=c[i]+v1[i];
  52. assert(c[i] > 0 && c[i] <= cc);
  53. fout<<c[i]<<' ';
  54. }
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement