답안 #7892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7892 2014-08-23T14:50:12 Z paulsohn 공주님의 정원 (KOI11_flower) C++
18 / 18
40 ms 1088 KB
#include<stdio.h>
int days[12] = { 0, 0, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30 }, N, bloom[276] = { 0 }, flower[275] = { 0 }, cnt = 0;
int main(){
	int m1, d1, m2, d2, rise, fall, front=0;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i){
		scanf("%d %d %d %d", &m1, &d1, &m2, &d2);
		if (m1 > 11 || m2 < 3) continue;
		rise = 1;
		fall = 275;
		if (m1 >= 3){
			rise = d1;
			for (int m = 3; m < m1; ++m)
				rise += days[m];
		}
		if (m2 <= 11){
			fall = d2 - 1;
			for (int m = 3; m < m2; ++m)
				fall += days[m];
		}
		if (bloom[rise]<fall) bloom[rise] = fall;
	}
	for (int day = 1; day < 276; ++day){
		if (front==0 || bloom[flower[front - 1]] < bloom[day]) flower[front++] = day;
	}
	if (flower[0]>1 || bloom[flower[front - 1]]<275){
		printf("0\n");
		return 0;
	}
	for (int k = front-1; k >= 0; --k){
		int j;
		++cnt;
		if (k == 0) break;
		for (j = k; j > 0; --j){
			if (bloom[flower[j-1]] < flower[k]-1) break;
		}
		if (j && j == k) {
			printf("0\n");
			return 0;
		}
		k = j + 1;
	}
	printf("%d\n", cnt);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1088 KB Output is correct
2 Correct 0 ms 1088 KB Output is correct
3 Correct 0 ms 1088 KB Output is correct
4 Correct 0 ms 1088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1088 KB Output is correct
2 Correct 0 ms 1088 KB Output is correct
3 Correct 0 ms 1088 KB Output is correct
4 Correct 0 ms 1088 KB Output is correct
5 Correct 0 ms 1088 KB Output is correct
6 Correct 4 ms 1088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1088 KB Output is correct
2 Correct 8 ms 1088 KB Output is correct
3 Correct 12 ms 1088 KB Output is correct
4 Correct 16 ms 1088 KB Output is correct
5 Correct 4 ms 1088 KB Output is correct
6 Correct 24 ms 1088 KB Output is correct
7 Correct 28 ms 1088 KB Output is correct
8 Correct 40 ms 1088 KB Output is correct
9 Correct 32 ms 1088 KB Output is correct
10 Correct 32 ms 1088 KB Output is correct