http://codeforces.com/contest/452

D题 Washer, Dryer, Folder

就算不用 DP,直接模拟还是没有问题的~

const int mx = 1e7 + 5;
int num[mx];
int main()
{
    int k, a, b, c, d, e, f, x;
    scanf("%d%d%d%d%d%d%d", &k, &a, &b, &c, &d, &e, &f);
    for (int timer = 0; timer < mx; ++timer)
    {
        if (timer >= d) a += num[timer - d]; // 更新空闲的机器数
        if (timer >= e) b += num[timer - e];
        if (timer >= f) c += num[timer - f];
        num[timer] = x = min(min(a, b), c);
        a -= x, b -= x, c -= x; // 空闲的机器->正在运行的机器
        k -= x;
        if (k <= 0) return printf("%d\n", timer + d + e + f), 0;
    }
}

Comments

comments powered by Disqus