Пример #1
0
    public static void Solve()
    {
        var n = I;
        var m = I;
        var p = new long[m];
        var a = new double[m];
        var b = new double[m];

        Repeat(m, i =>
        {
            p[i] = L - 1;
            a[i] = D;
            b[i] = D;
        });

        if (m == 0)
        {
            Console.WriteLine(1.0);
            Console.WriteLine(1.0);
            return;
        }

        var comp = new CoordinateCompressor <long>(p);

        var st = SegmentTree.Create(m, Monoid.Create(
                                        Tuple.Create(1.0, 0.0),
                                        (x, y) => Tuple.Create(x.Item1 * y.Item1, x.Item2 * y.Item1 + y.Item2)));

        var min = 1.0;
        var max = 1.0;

        Repeat(m, i =>
        {
            var cp  = comp.Compress[p[i]];
            st[cp]  = Tuple.Create(a[i], b[i]);
            var crt = st[0, m - 1];
            var d   = crt.Item1 + crt.Item2;
            min     = Min(min, d);
            max     = Max(max, d);
        });

        Console.WriteLine(min);
        Console.WriteLine(max);
    }