fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. public class Main
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner sc = new Scanner(System.in);
  13. int n = sc.nextInt();
  14. int m = sc.nextInt();
  15. int k = sc.nextInt();
  16. int[] a = new int[n+1];
  17. for(int i=1;i<=n;i++)
  18. {
  19. a[i]=sc.nextInt();
  20. }
  21. int[][] op = new int[m+1][3];
  22. for(int i=1;i<=m;i++)
  23. {
  24. op[i][0]=sc.nextInt(); //l
  25. op[i][1]=sc.nextInt(); //r
  26. op[i][2]=sc.nextInt(); //d
  27. }
  28. int[] count= new int[m+2];
  29. for(int i=0;i<k;i++)
  30. {
  31. int x = sc.nextInt();
  32. int y = sc.nextInt();
  33. count[x]++;
  34. count[y+1]--;
  35.  
  36. }
  37. for(int i=1;i<=m;i++)
  38. {
  39. count[i]+=count[i-1];
  40. }
  41. long[] diff = new long[n+2];
  42. for(int i=1;i<=m;i++)
  43. {
  44. int l = op[i][0];
  45. int r = op[i][1];
  46. int d = op[i][2];
  47. diff[l]+=(long)d*count[i];
  48. diff[r+1]-=(long)d*count[i];
  49. }
  50. long[] pre_diff = new long[n+2];
  51. for(int i=1;i<=n;i++)
  52. {
  53. pre_diff[i]=pre_diff[i-1]+diff[i];
  54. }
  55. for(int i=1;i<=n;i++)
  56. {
  57. a[i]+=pre_diff[i];
  58. System.out.print(a[i]+" ");
  59. }
  60. System.out.println();
  61. }
  62. }
Success #stdin #stdout 0.17s 59104KB
stdin
4 3 6
1 2 3 4
1 2 1
2 3 2
3 4 4
1 2
1 3
2 3
1 2
1 3
2 3
stdout
5 18 31 20