Submission #7892

#TimeUsernameProblemLanguageResultExecution timeMemory
7892paulsohn공주님의 정원 (KOI11_flower)C++98
18 / 18
40 ms1088 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...