[题解]ZOJ Monthly, July 2011beta » ZOJ3518

ZOJ3518
ZOJ3518.cpp


#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

bool bs[10001000];

int main() {
	int l, n1, n2, a, b, ans;

	while (scanf("%d%d%d", &l, &n1, &n2) != EOF) {
		n1 += n2;
		fill(bs, bs + l + 1, false);
		for (int i = 0; i < n1; ++i) {
			scanf("%d%d", &a, &b);
			transform(bs + a, bs + b + 1, bs + a, logical_not<bool>());
		}
		ans = 0;
		for (int i = 0; i <= l; ) {
			if (bs[i]) {
				int j = find(bs + i, bs + l + 1, false) - bs;
				ans = max(ans, j - i);
				i = j;
			} else {
				++i;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

//Run ID 	Submit Time 	Judge Status 	Problem ID 	Language 	Run Time(ms) 	Run Memory(KB) 	User Name 	Admin
//764 	2011-06-20 22:42:57 	Accepted 	I 	C++ 	180 	9948 	admin 	Source
One Response to “ZOJ3518”
  1. creepyuncle says:

    总能在shi哥的代码里发现自己不知道的c++模板函数和使用方法。。。

  2.  
Leave a Reply