题目链接:https://codeforces.com/contest/1418/problem/C
#include<bits/stdc++.h>typedef long long ll;
using namespace std;
const int N = 2e5+5;
const int inf = 0x5fffff;
int a[N];
int dp[N][2];void init(int n){
for(int i =0;i<=n;i++)for(int j =0;j<2;j++)dp[i][j]=inf;
}
void solve(){
int n;cin>>n;init(n);for(int i=1;i<=n;i++){
cin>>a[i];}dp[1][0]=a[1];dp[2][0]=a[1]+a[2];for(int i=1;i<=n;i++){
dp[i+1][1]=min(dp[i+1][1],dp[i][0]);dp[i+2][1]=min(dp[i+2][1],dp[i][0]);dp[i+1][0]=min(dp[i+1][0],dp[i][1]+a[i+1]);dp[i+2][0]=min(dp[i+2][0],dp[i][1]+a[i+1]+a[i+2]);}cout<<min(dp[n][0],dp[n][1])<<"\n";}int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int __ = 1;cin>>__;while (__--) {
solve();}}