MAGCARI

Mixing

Jul 5th, 2022 (edited)
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a[1000010];
  4. int main(){
  5.     int q,n;
  6.     scanf("%d",&q);
  7.     while(q--){
  8.         scanf("%d",&n);
  9.         long long ans = 0;
  10.         for(int i=1;i<=n;i++){
  11.             scanf("%d",&a[i]);
  12.             if(i>=2)
  13.                 ans+=max(a[i],a[i-1]);
  14.         }
  15.         printf("%lld\n",ans);
  16.     }
  17.     return 0;
  18. }
RAW Paste Data Copied