http://poj.org/problem?id=1017
艰难啊
弄了很久咧
拍了几十万组,以后拍要多组数据
Solution
从大wangxiaofang
从大往小放,有空余的从大往小填
注意细节
Notice
b<0的情况,还有就是当前填充完了,还剩一点给下一个(小一点的)填
Code
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define MOD 1000000007
#define INF 1e9
using namespace std;
typedef long long LL;
const int MAXN=100010;
const int MAXM=100010;
inline int gi() {
register int w=0,q=0;register char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')q=1,ch=getchar();
while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar();
return q?-w:w;
}
int main()
{
freopen("1017.in","r",stdin);
freopen("1017.out","w",stdout);
int ans,a,b,c,d,e,f,x;
while(a=gi(),b=gi(),c=gi(),d=gi(),e=gi(),f=gi(),a||b||c||d||e||f){
ans=d+e+f;if(c)ans+=(c-1)/4+1;
if(d*5>b)a-=(d*5-b)*4;
a-=11*e;b-=d*5;x=(4-c%4)*2-1;
if(c%4!=0)a-=(4-c%4)*9-min(x,(b<0?0:b))*4;
//this b<0 & min
if(c%4!=0)b-=x;if(b>0)ans+=(b-1)/9+1;
if(b>0&&b%9!=0)a-=(9-b%9)*4;
if(a>0)ans+=(a-1)/36+1;
printf("%d\n",ans);
}
return 0;
}