思路:
这题就是一道模拟题
可以用个数组预处理一下每个月有几天
C o d e Code Code:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int x[13] = {
0,31,60,91,121,152,182,213,244,274,305,335,366};
int n;
int month[4001],day[4001],skytime[4001];//skytime是在天上的时间
int main ()
{
scanf("%d", &n);
for (int i = 1; i <= n ; ++i)
scanf("%d%d", &month[i], &day[i]);
for (int i = 1; i <= n - 1; ++i)
for (int j = i + 1; j <= n; ++j)
if (month[j] < month[i] || month[j] == month[i] && day[j] < day[i])
{
swap (month[j],month[i]);
swap (day[j],day[i]);
}
skytime[1] = x[month[1] - 1] + day[1] - 1;
for (int i = 2; i <= n; ++i)
skytime[i] = x[month[i] - 1] - x[month[i - 1] - 1] + day[i] - day[i - 1] - 1;
skytime[n + 1] = x[12] - x[month[n] - 1] - day[n];
sort(skytime + 1, skytime + 1 + n + 1);
printf("%.lf",round((skytime[n + 1] * 1.0) / 366 * 86400));
return 0;
}