#include<stdio.h>
int N;
int date[14]={0,31,59,90,120,151,181,212,243,273,304,334,};
int T[400], D[400];
int df(int x,int y){return date[x-1]+y;}
int ans;
int input(){
scanf("%d",&N);
int a,b,c,d;
for(int i=0;i<400;i++)T[i] = 1000;
for(int i=0;i<N;i++){
scanf("%d %d %d %d",&a,&b,&c,&d);
if(T[df(c,d)]>df(a,b))T[df(c,d)]=df(a,b);
}
return 0;
}
int solve(){
for(int i=0;i<400;i++)D[i] = 1000;
ans = 1000;
for(int i=0;i<df(3,1);++i)D[i] = 0;
for(int i=df(3,1);i<=df(12,31);++i)for(int j=T[i];j<i;j++)if(D[i] > D[j] + 1)D[i] = D[j] + 1;
for(int i=df(11,30);i<=df(12,31);++i)if(ans > D[i])ans = D[i];
if(ans == 1000)ans = 0;
return 0;
}
int output(){
printf("%d",ans);
return 0;
}
int main(){
input();
solve();
output();
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1088 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
1088 KB |
Output isn't correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1088 KB |
Output is correct |
2 |
Correct |
8 ms |
1088 KB |
Output is correct |
3 |
Correct |
8 ms |
1088 KB |
Output is correct |
4 |
Correct |
12 ms |
1088 KB |
Output is correct |
5 |
Correct |
16 ms |
1088 KB |
Output is correct |
6 |
Incorrect |
12 ms |
1088 KB |
Output isn't correct |
7 |
Correct |
16 ms |
1088 KB |
Output is correct |
8 |
Correct |
32 ms |
1088 KB |
Output is correct |
9 |
Incorrect |
28 ms |
1088 KB |
Output isn't correct |
10 |
Correct |
40 ms |
1088 KB |
Output is correct |