传送门
题意: 就有个初始时间和结束时间,给出n个题的AC时间,试问这段时间24小时不停歇最多能AC多少题。
思路: 其实也没大好说的,就是模拟求时间段总共有多少分钟,然后再将n个问题sort一下求答案即可。
代码实现:
#include
#define endl '\n'
#define null NULL
#define ll long long
#define int long long
#define pii pair
#define lowbit(x) (x &(-x))
#define ls(x) x<<1
#define rs(x) (x<<1+1)
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const int inf = 0x7fffffff;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
int n, a[N];
int year = 365, yearr = 366;
int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int monthr[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
int year1, month1, day1, hour1, min1;
int year2, month2, day2, hour2, min2;
ll time1, time2;
int check(int x){
if(((x%4 == 0) && (x%100 != 0)) || ((x%100 == 0) && (x%400 == 0))) return 1;
else return 0;
}
ll work(ll year3, ll month3, ll day3, ll hour3, ll min3){
int flag = check(year3), time = 0;
for(int i = 0; i < year3; i ++){
if(check(i)) time += yearr*24*60;
else time += year*24*60;
}
ll monthtime = 0;
for(int i = month3 - 1; i >= 0; i --){
if(flag) monthtime += monthr[i]*24*60;
else monthtime += month[i]*24*60;
}
time += min3 + hour3*60 + (day3-1)*24*60 + monthtime;
return time;
}
signed main()
{
scanf("%d",&n);
for(int i = 1; i <= n; i ++) cin >> a[i];
sort(a + 1, a + n + 1);
scanf("%lld-%lld-%lld-%lld:%lld", &year1, &month1, &day1, &hour1, &min1);
scanf("%lld-%lld-%lld-%lld:%lld", &year2, &month2, &day2, &hour2, &min2);
ll ans = work(year2, month2, day2, hour2, min2) - work(year1, month1, day1, hour1, min1);
int tmp = 0;
for(int i = 1; i <= n; i ++){
if(ans-a[i] >= 0){
tmp ++;
ans -= a[i];
}
}
cout << tmp << endl;
return 0;
}