/* yukicoder My Practice * autoher: Leonarone NEETSDKASU ************************************************************************/ #include #include #include #include #include /************************************************************************/ #define MR__BUFSIZE (1000000) typedef struct _string { size_t len; char *data; } string; char mr__buffer[MR__BUFSIZE], *mr__start=mr__buffer; size_t mr__buflen; void solve(void); int main(void) { mr__buflen = fread(mr__buffer, sizeof(mr__buffer[0]), sizeof(mr__buffer) / sizeof(mr__buffer[0]), stdin); if (mr__buflen < MR__BUFSIZE - 1) mr__buffer[mr__buflen] = '\n'; else exit(EXIT_FAILURE); solve(); return 0; } #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define rep(i,s,e) for(i=s;isize=n; r->capa=a; return r; } void extendVec(PPVector p, size_t b) { Vector v=*p;if(v->size==v->capa){v->capa+=V_ALLOCSIZE; v=*p=(Vector)realloc(*p,v->capa*b+sizeof(VectorT));}} #define CUP(a, b) a##b #define CUP3(a, b, c) a##b##c #define VEC_DEF(_T,_I) \ typedef struct CUP3(_,_I,vector) { size_t size; size_t capa; _T value[0]; } CUP(_I,VectorT),*CUP(_I,Vector),**CUP3(PP,_I,Vector); \ CUP(_I,Vector) CUP3(new,_I,V)(size_t n) { return (CUP(_I,Vector))newVec(n,sizeof(_T)); } \ CUP(_I,Vector) CUP3(add,_I,V)(CUP3(PP,_I,Vector) p, _T x) { extendVec((PPVector)p, sizeof(_T)); (*p)->value[(*p)->size++]=x; return *p; } VEC_DEF(int,I); VEC_DEF(string,S); VEC_DEF(IVector,IV); VEC_DEF(SVector,SV); VEC_DEF(char,C); SVector strsplit(string str, char d) {SVector vec=newSV(0);char *e=str.data,*s;string t; for(;;){s=e;while(*e&&*e!=d)e++;if(e==str.data)return vec;t.data=s;t.len=e-s;addSV(&vec,t);if(*e==0)break;*e++=0;}return vec;} string strjoin(SVector v,char d){string t,r={0};int i;for(i=0;isize;i++)r.len+=v->value[i].len;if(d)r.len+=v->size-1; {char *p=r.data=(char*)malloc(sizeof(char)*(r.len+1));for(i=0;isize;i++) {if(i&&d)*p++=d;t=v->value[i];memcpy(p,t.data,t.len*sizeof(char));p+=t.len;}r.data[r.len]=0;}return r;} int isEOF(void) { return *mr__start == '\0'; } void nextLine(void) { while (*mr__start != '\n') mr__start++; *mr__start++ = '\0'; } int ti(string s) { int i,r=0,m=*s.data=='-'; for(i=m;i<(int)s.len;i++)r=r*10+(int)(s.data[i]-'0'); return m ? -r : r; } string gs(void) { string r = {0, mr__start}; nextLine(); r.len = mr__start - r.data - 1; return r; } int gi(void) { return ti(gs()); } SVector gss(void) { return strsplit(gs(), ' '); } IVector gis(void) { SVector v=gss();IVector r=newIV(v->size);int i;for(i=0;isize;i++)r->value[i]=ti(v->value[i]);free(v);return r;} SVector ngs(int n) { SVector r=newSV(n); int i; for(i=0;ivalue[i]=gs(); return r; } IVector ngi(int n) { IVector r=newIV(n); int i; for(i=0;ivalue[i]=gi(); return r; } SVVector ngss(int n) { SVVector r=newSVV(n); int i; for(i=0;ivalue[i]=gss(); return r; } IVVector ngis(int n) { IVVector r=newIVV(n); int i; for(i=0;ivalue[i]=gis(); return r; } /************************************************************************/ void solve(void) { IVector LLL = gis(); IVector RBY = gis(); Dv3(int, RBY->value, r, b, y); IVector comb = newIV(0), res = newIV(0); int i, j, k, *p; REP(i,2) { rep(j,i+1,3) { addIV(&comb, (LLL->value[i] + LLL->value[j]) * 2); } } p = comb->value; REP(i,3) { REP(j,3) { if (i-j) REP(k,3) { if (i-k&&j-k) addIV(&res, p[i] * r + p[j] * b + p[k] * y ); } } } p = res->value; rep(i,1,res->size) { if (*p>res->value[i]) p=res->value + i; } printf("%d\n", *p); }