【Codeforces 712C】Memory and De-Evolution

题目传送门:http://codeforces.com/contest/712/problem/C
官方题解:http://codeforces.com/blog/entry/47050
中文题面:http://blog.csdn.net/queuelovestack/article/details/52503162

这个题目考试的时候,看到都有1000+的人A掉了
然而我还是一脸懵逼
虽然看了题解以后,感觉题还不错,但为什么一点不觉得这个题好QAQ
一定是被恶心到了…..

考虑倒着贪心。
首先每一条边,只会成为限制,且这个限制越大越好
所以,肯定是每一次选择一条边加到上限
至于是哪一条边,肯定是最短的那条边对于周长的贡献最大

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

inline int read(){
	char c=getchar(); int ret=0,f=1;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret*f;
}

int main(){
	int arr[4],pur=read(),vout=0;
	arr[1] = arr[2] = arr[3] = read();
	while (arr[1] < pur) {
		arr[1] = min(pur,arr[2]+arr[3]-1);
		sort(arr+1,arr+1+3); vout++;
	} cout<<vout<<endl;
	return 0;
}

2 thoughts to “【Codeforces 712C】Memory and De-Evolution”

  1. Very nice post. I just stumbled upon your weblog and wished to say that I’ve really enjoyed surfing around your blog posts. After all I’ll be subscribing to your feed and I hope you write again very soon!

  2. I am curious to find out what blog system you’re utilizing? I’m having some small security issues with my latest blog and I would like to find something more safeguarded. Do you have any recommendations?

Leave a Reply

Your email address will not be published. Required fields are marked *