Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
简单贪心....0ms水过#include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> #define INT_MAX 1<<30 using namespace std; typedef long long ll; const int INF=0x7F; int n; int a[7]; bool bl=false; int ans=0; int main() { while (1) { bl=false; ans=0; for (int i = 1; i <= 6; i += 1) { scanf("%d",&a[i]); if(a[i])bl=true; } if(!bl)break; ans+=a[6]; ans+=a[5]; if(a[1]<=11*a[5])a[1]=0; else a[1]-=11*a[5]; ans+=a[4]; if(a[2]<=5*a[4]){ int left=20*a[4]-a[2]*4; if(a[1]<=left)a[1]=0; else a[1]-=left; a[2]=0; } else { int left=20*a[4]-5*a[4]*4; if(a[1]<=left)a[1]=0; else a[1]-=left; a[2]-=5*a[4]; } ans+=a[3]/4; a[3]=a[3]%4; if(a[3]>0){ ans+=1; if(a[2]<=7-a[3]*2){ int left=36-a[3]*9-a[2]*4; if(a[1]<=left)a[1]=0; else a[1]-=left; a[2]=0; } else { int left=36-a[3]*9-(7-a[3]*2)*4; if(a[1]<=left)a[1]=0; else a[1]-=left; a[2]=a[2]-(7-a[3]*2); } a[3]=0; } if(a[2]>0){ ans+=a[2]/9; a[2]=a[2]%9; if(a[2]>0){ ans+=1; int left=36-a[2]*4; if(a[1]<=left)a[1]=0; else { a[1]-=left; a[2]=0; } } } if(a[1]>0){ ans+=a[1]/36; a[1]=a[1]%36; if(a[1]!=0)ans++; } printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator