Analysis

a1 + a2 + a1 * b2 <= a2 + a1 + a2 * b1（即：1 先 2 后的总时间 <= 2 先 1 后的总时间）

a2 + a3 + a2 * b3 <= a3 + a2 + a3 * b2

a1 * b2 <= a2 * b1（喵）

a2 * b3 <= a3 * b2（汪）

a1 + a3 + a1 * b3 <= a3 + a1 + a3 * b1

a1 * b3 <= a3 * b1

a1 * b2 * b3 <= a2 * b1 * b3

a2 * b1 * b3 <= a3 * b1 * b2

a1 * b2 * b3 <= a2 * b1 * b3 <= a3 * b1 * b2

a1 * b2 * b3 <= a3 * b1 * b2

a1 * b3 <= a3 * b1

Code

#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 100000, MOD = 365*24*60*60;

struct node
{
int a, b;
bool operator < (const node &rhs) const
{
return (long long)a * rhs.b < (long long)rhs.a * b;
}
} sub[N];

int main()
{
int n;
while(scanf("%d", &n), n)
{
for(int i=0; i<n; ++i)
scanf("%d%d", &sub[i].a, &sub[i].b);
sort(sub, sub + n);
long long tm = 0;
for(int i=0; i<n; ++i)
tm = (tm + tm * sub[i].b % MOD + sub[i].a) % MOD;
printf("%lld\n", tm);
}
return 0;
}

HDU 4442 Physical Examination

2012-10-29 18:04:44

HDU 4442 Physical Examination

2014-04-03 20:05:21

hdu - 4442 - Physical Examination

2013-02-16 09:55:09

hdu 4442 Physical Examination

2016-10-05 23:30:09

HDU 4442 - Physical Examination（贪心）

2014-12-01 21:41:11

HDU 4442 Physical Examination（贪心）

2016-11-02 15:13:59

HDU 4442 Physical Examination (贪心选择）

2015-10-29 10:56:41

hdu 4442 Physical Examination (排序)

2014-10-20 16:47:12

hdu 4442 Physical Examination（贪心）

2014-10-24 23:14:19

hdu 4442 Physical Examination（水题）

2014-11-01 11:56:04