// Problem: No.2617 容量3のナップザック // Contest: yukicoder // URL: https://yukicoder.me/problems/no/2617 // Memory Limit: 512 MB // Time Limit: 2000 ms #include #define debug(x) cerr<<(#x)<<" "<<(x)< #define rep(i,a,b) for(ll i=(a);i<=(b);++i) #define per(i,a,b) for(ll i=(a);i>=(b);--i) using namespace std; bool Mbe; ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void write(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+'0'); } const ll N=2e6+9; ll n,k,seed,A,B,m,v[N],f[N],w[N],b1[N],b2[N],b3[N],t1,t2,t3,p1,p2,c,sum,ans; void add(){ ll v1=b1[p1+1]+b2[p2+1]; ll v2=b1[p1+1]+b1[p1+2]+b1[p1+3]; if(v1==0&&v2==0)return; if(v1>v2)sum+=v1,p1++,p2++; else sum+=v2,p1+=3; } bool Med; int main(){ cerr<