View Code of Problem 88

#include<bits/stdc++.h>
using namespace std;

int main() {

	int have[7];
	int sheng[7]={0};
	for(int i=1;i<=6;i++){
		cin>>have[i];
	}
	int num=0;
	while(have[6]>0){
		have[6]--;
		num++;
	}
	while(have[5]>0){
		have[5]--;
		num++;
		sheng[1]+=11;
		while(have[1]>0&&sheng[1]>0){
			sheng[1]--;
			have[1]--;
		}
	}
	while(have[4]>0){
		have[4]--;
		num++;
		sheng[2]+=5;
		while(have[2]>0&&sheng[2]>0){
			sheng[2]--;
			have[2]--;
		}
	}
	while(have[3]>0){
		have[3]--;
		num++;
		sheng[3]+=3;
		while(have[3]>0&&sheng[3]>0){
			sheng[3]--;
			have[3]--;
		}
	}
	
	while(have[2]>0){
		while(sheng[3]>0){
			sheng[3]--;
			sheng[2]+=1;
			sheng[1]+=5;
		}
		if(sheng[2]>0){
			sheng[2]--;
			have[2]--;
		}else{
			num++;
		}
	}
	while(have[1]>0){
		while(sheng[2]>0){
			sheng[2]--;
			sheng[1]+=4;
		}
		if(sheng[1]>0){
			sheng[1]--;
			have[1]--;
		}else{
			num++;
		}
	}
	cout<<num<<endl;
	return 0;
}

Double click to view unformatted code.


Back to problem 88