Submission #6075

#TimeUsernameProblemLanguageResultExecution timeMemory
6075leecs0503쌍둥이 독수리 (GA7_twineagles)C++98
11 / 100
0 ms1088 KiB
#include<stdio.h>


//FILE *input=freopen("input.txt","r",stdin);

long long int swap(long long int &a,long long int &b){
	long long int c;
	c=a;
	a=b;
	b=c;
}

int main(){
	long long int lh,s,e,l,b;
	long long int olh,ols,ole,oll,olb;
	long long int cnt=0,cnt2;
	long long int k;
	long long int first;
	scanf("%lld%lld%lld%lld%lld",&lh,&s,&e,&l,&b);
	olh=lh;
	ols=s;
	ole=e;
	oll=l;
	olb=b;

	swap(l,b);
	swap(s,e);
	lh=olh;
	s=ols;
	e=ole;
	l=oll;
	lh=olh;
	cnt=0;
	cnt2=0;
	//l>=b
	if(s<=lh&&e<=lh){
		cnt=1;
	}
	else{
	if(lh*2<l&&s<lh*2){
		s=0;
		cnt=1;
		e+=b;
	}
	else{
	k=lh*2-l;
	if(s>lh*2)
	{
		cnt=(s-lh*2)/k;
		s-=cnt*k;
		e+=cnt*b;
		if(s>lh*2){
			s-=k;
			cnt++;
			e+=b;
		}
	}
	else{
		cnt=0;
	}
	if(s==0){
	}
	else if(s<=lh){
		s=0;
		e-=lh;
		if(e>0)
			e+=b;
		cnt++;
	}
	else{
		s=0;
		cnt++;
		e+=b;
	}
	}
	k=lh*2-b;
	if(e>lh*2){
		cnt2=(e-lh*2)/k;
		cnt+=cnt2;
		e-=cnt2*k;
		if(e>lh*2){
			e-=k;
			cnt++;
		}
	}
	else{
	}
	if(e<=0){
	}
	else{
		cnt++;
	}
	}
	first=cnt;
	swap(l,b);
	swap(s,e);
	lh=olh;
	s=ols;
	e=ole;
	l=oll;
	lh=olh;
	cnt=0;
	cnt2=0;
	//l>=b
	if(s<=lh&&e<=lh){
		cnt=1;
	}
	else{
	if(lh*2<l&&s<lh*2){
		s=0;
		cnt=1;
		e+=b;
	}
	else{
	k=lh*2-l;
	if(s>lh*2)
	{
		cnt=(s-lh*2)/k;
		s-=cnt*k;
		e+=cnt*b;
		if(s>lh*2){
			s-=k;
			cnt++;
			e+=b;
		}
	}
	else{
		cnt=0;
	}
	if(s==0){
	}
	else if(s<=lh){
		s=0;
		e-=lh;
		if(e>0)
			e+=b;
		cnt++;
	}
	else{
		s=0;
		cnt++;
		e+=b;
	}
	}
	k=lh*2-b;
	if(e>lh*2){
		cnt2=(e-lh*2)/k;
		cnt+=cnt2;
		e-=cnt2*k;
		if(e>lh*2){
			e-=k;
			cnt++;
		}
	}
	else{
	}
	if(e<=0){
	}
	else{
		cnt++;
	}
	}
	if(first<cnt)
		printf("%lld",first);
	else
		printf("%lld",cnt);

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...