Advertisement
4doorsmorehories

Untitled

Apr 19th, 2024
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int t,a,n,i,q;
  6.     scanf("%d",&t);
  7.     while(t--)
  8.     {
  9.         scanf("%d",&n);
  10.         long int l,r,w,sum = 0;
  11.         for(i=0;i<n;i++)
  12.         {
  13.             scanf("%d",&a);
  14.             sum= sum+a;
  15.         }
  16.         scanf("%d",&q);
  17.         while(q--)
  18.         {
  19.             scanf("%ld%ld%ld",&l,&r,&w);
  20.             sum = sum+(r-l+1)*w;
  21.         }
  22.         printf("%ld\n",sum);
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement