답안 #16247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16247 2015-08-18T11:22:12 Z eaststar 공주님의 정원 (KOI11_flower) C++14
18 / 18
82 ms 1864 KB
#include<stdio.h>   
int n;   
int months[100]={0,31,28,31,30,31,30,31,31,30,31,30,31};   
struct A {   
    int start,end;   
};   
int days(int month,int day) {   
    int i;   
    int sum=0;   
    for(i=1;i<month;i++) sum+=months[i];   
    return sum+day;   
}   
A flowers[100011];   
int main() {
    scanf("%d",&n);   
    int i,j;   
    for(i=1;i<=n;i++) {   
        int s,e,ss,ee;   
        scanf("%d%d%d%d",&s,&e,&ss,&ee);   
        flowers[i].start = days(s,e);   
        flowers[i].end = days(ss,ee)-1;   
    }   
    int tear=0;   
    for(i=1;i<=n;i++) {   
        if(flowers[i].start <= days(3,1) && tear < flowers[i].end) {   
            tear=flowers[i].end;   
        }   
    }   
    if(tear == 0) {   
        printf("0");   
        return 0;   
    }   
    int cnt=1;   
    for(i=1;i<=365;i++) {   
        bool t=false;   
        int mx=0;   
        for(j=1;j<=n;j++) {   
            if(flowers[j].start <= tear+1 && flowers[j].end > mx) {   
                mx=flowers[j].end;   
                t=true;   
            }   
        }   
        if(!t || tear >= mx) {   
            printf("0");   
            return 0;   
        } else {   
            tear = mx;   
            cnt++;   
        }   
        if(tear >= days(11,30)) break;   
    }   
    printf("%d",cnt);
	return 0;
}  
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
5 Correct 5 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 16 ms 1864 KB Output is correct
4 Correct 18 ms 1864 KB Output is correct
5 Correct 21 ms 1864 KB Output is correct
6 Correct 27 ms 1864 KB Output is correct
7 Correct 26 ms 1864 KB Output is correct
8 Correct 11 ms 1864 KB Output is correct
9 Correct 82 ms 1864 KB Output is correct
10 Correct 53 ms 1864 KB Output is correct