现在的位置: 首页 > 综合 > 正文

SRM602 (div2)

2018年12月25日 ⁄ 综合 ⁄ 共 1259字 ⁄ 字号 评论关闭

 TypoCoderDiv2 
 

没注意:their rating is 500 !!! 打脸。。

 PilingRectsDiv2

简单的暴力:

class PilingRectsDiv2 {
public:
	int getmax(vector <int>, vector <int>, int);
};

int PilingRectsDiv2::getmax(vector <int> X, vector <int> Y, int limit) {
	int ans = 0, i, j, k, Max;
	for(i=1; i<=200; ++i) 
	for(j=1; j<=200; ++j){
		if(i*j >= limit) {
			Max = 0;
			for(k=0; k<X.size(); ++k){
				if( (X[k]>=i&&Y[k]>=j) || (X[k]>=j&&Y[k]>=i) )
					Max++;
			}
			if(Max > ans ) ans = Max;
		}
	}
	if(ans == 0) return -1;
	else return ans;
}

还可以用记忆化搜索做(别人的代码):

int
solve (int idx, int l, int b) {
    if (idx == N) {
        if (l == LIM && b == LIM) return -1;
        if (l * b >= lim) return 0;
        if (l * b < lim) return -INF;
    }
    if (memo [idx][l][b] != -1) return memo [idx][l][b];
    int ret = 0;
    ret = 1 + max (solve (idx + 1, min (L [idx], l), min (B [idx], b)),
                   solve (idx + 1, min (B [idx], l), min (L [idx], b)));
    ret = max (ret, solve (idx + 1, l, b));
    return memo [idx][l][b] = ret;
}
 
class PilingRectsDiv2 {
    public:
    int
    getmax(vector<int> X, vector<int> Y, int limit) {
        L = X; B = Y;
        memset (memo, -1, sizeof (memo));
        LIM = 202;
        lim = limit;
        N = len (X);
        return solve (0, LIM, LIM);
    }
};

 BlackBoxDiv2

没看,不会做。

先留着,以后解决。

http://community.topcoder.com/stat?c=problem_solution&rd=15820&pm=12929&cr=23288241

http://community.topcoder.com/stat?c=problem_solution&rd=15820&pm=12929&cr=23282585

http://community.topcoder.com/stat?c=problem_solution&rd=15820&pm=12929&cr=23288971

http://community.topcoder.com/stat?c=problem_solution&rd=15820&pm=12929&cr=23137498

抱歉!评论已关闭.