Submission #997868


Source Code Expand

using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Number = System.Int64;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {

            var n = sc.Integer();
            var m = sc.Integer();
            var k = sc.Integer();
            var seg = Enumerate(k + 1, x => new RMQSegmentTree(n + 1));
            seg[0].Update(0, 0);
            var a = new int[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = sc.Integer();
            for (int i = 1; i <= k; i++)
                for (int j = 1; j <= n; j++)
                {
                    var max = seg[i - 1].Query(Math.Max(0, j - m), j);
                    seg[i].Update(j, max + 1L * i * a[j]);

                }
            IO.Printer.Out.WriteLine(seg[k].Query(0, n + 1));

        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }


    }
}
#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion

#region RMQ Segment Tree
public class RMQSegmentTree
{
    const Number ZERO = -1;
    int n;
    Number[] data;
    public RMQSegmentTree(int size)
    {
        n = 1;
        while (n < size)
            n <<= 1;
        data = new Number[n << 1];
        for (int i = 0; i < data.Length; i++)
            data[i] = ZERO;
    }
    public void Update(int k, Number v)
    {
        k += n;
        data[k] = v;
        k >>= 1;
        while (k > 0)
        {
            data[k] = merge(data[k << 1], data[(k << 1) + 1]);
            k >>= 1;
        }

    }
    public Number Query(int a, int b) { return query(a, b, 1, 0, n); }
    private Number query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
            return ZERO;
        if (a <= l && r <= b)
            return data[k];
        else
        {
            var vl = query(a, b, k << 1, l, (l + r) >> 1);
            var vr = query(a, b, (k << 1) + 1, (l + r) >> 1, r);
            return merge(vl, vr);
        }
    }
    Number merge(Number l, Number r)
    {
        return Math.Max(l, r);
    }
    public Number[] Items
    {
        get
        {
            var ret = new Number[n];
            for (int i = 0; i < n; i++)
                ret[i] = data[i + n];
            return ret;
        }
    }

}
#endregion

Submission Info

Submission Time
Task A - Struck Out
User camypaper
Language C# (Mono 4.6.2.0)
Score 0
Code Size 6489 Byte
Status WA
Exec Time 2134 ms
Memory 620680 KB

Judge Result

Set Name Sample subtask1 subtask2 subtask3 All
Score / Max Score 0 / 0 0 / 100 0 / 200 0 / 300 0 / 100
Status
AC × 3
AC × 5
WA × 2
TLE × 3
AC × 9
WA × 3
AC × 15
WA × 6
AC × 20
WA × 8
TLE × 15
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt
subtask1 sample_2.txt, subtask_1_1.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
subtask2 sample_1.txt, sample_2.txt, sample_3.txt, subtask_2_1.txt, subtask_2_2.txt, subtask_2_3.txt, subtask_2_4.txt, subtask_2_5.txt, subtask_2_6.txt, subtask_2_7.txt, subtask_2_8.txt, subtask_2_9.txt
subtask3 sample_1.txt, sample_2.txt, sample_3.txt, subtask_2_1.txt, subtask_2_2.txt, subtask_2_3.txt, subtask_2_4.txt, subtask_2_5.txt, subtask_2_6.txt, subtask_2_7.txt, subtask_2_8.txt, subtask_2_9.txt, subtask_3_1.txt, subtask_3_2.txt, subtask_3_3.txt, subtask_3_4.txt, subtask_3_5.txt, subtask_3_6.txt, subtask_3_7.txt, subtask_3_8.txt, subtask_3_9.txt
All sample_1.txt, sample_2.txt, sample_3.txt, subtask_1_1.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt, subtask_2_1.txt, subtask_2_2.txt, subtask_2_3.txt, subtask_2_4.txt, subtask_2_5.txt, subtask_2_6.txt, subtask_2_7.txt, subtask_2_8.txt, subtask_2_9.txt, subtask_3_1.txt, subtask_3_2.txt, subtask_3_3.txt, subtask_3_4.txt, subtask_3_5.txt, subtask_3_6.txt, subtask_3_7.txt, subtask_3_8.txt, subtask_3_9.txt, subtask_4_1.txt, subtask_4_10.txt, subtask_4_11.txt, subtask_4_12.txt, subtask_4_13.txt, subtask_4_2.txt, subtask_4_3.txt, subtask_4_4.txt, subtask_4_5.txt, subtask_4_6.txt, subtask_4_7.txt, subtask_4_8.txt, subtask_4_9.txt
Case Name Status Exec Time Memory
sample_1.txt AC 19 ms 2648 KB
sample_2.txt AC 20 ms 2648 KB
sample_3.txt AC 19 ms 2648 KB
subtask_1_1.txt AC 20 ms 2776 KB
subtask_1_2.txt AC 672 ms 81856 KB
subtask_1_3.txt TLE 2134 ms 620680 KB
subtask_1_4.txt AC 55 ms 7128 KB
subtask_1_5.txt AC 162 ms 15448 KB
subtask_1_6.txt WA 25 ms 3544 KB
subtask_1_7.txt TLE 2113 ms 210344 KB
subtask_1_8.txt TLE 2134 ms 620680 KB
subtask_1_9.txt WA 44 ms 6360 KB
subtask_2_1.txt AC 21 ms 3032 KB
subtask_2_2.txt WA 21 ms 2904 KB
subtask_2_3.txt AC 20 ms 2904 KB
subtask_2_4.txt AC 21 ms 2776 KB
subtask_2_5.txt WA 20 ms 2776 KB
subtask_2_6.txt WA 20 ms 2648 KB
subtask_2_7.txt AC 22 ms 3032 KB
subtask_2_8.txt AC 22 ms 3032 KB
subtask_2_9.txt AC 22 ms 2904 KB
subtask_3_1.txt AC 997 ms 66760 KB
subtask_3_2.txt AC 1176 ms 66752 KB
subtask_3_3.txt AC 1140 ms 64704 KB
subtask_3_4.txt WA 949 ms 66632 KB
subtask_3_5.txt AC 52 ms 6872 KB
subtask_3_6.txt WA 539 ms 35920 KB
subtask_3_7.txt AC 866 ms 66760 KB
subtask_3_8.txt AC 115 ms 10840 KB
subtask_3_9.txt WA 1050 ms 66760 KB
subtask_4_1.txt TLE 2134 ms 620680 KB
subtask_4_10.txt TLE 2134 ms 620680 KB
subtask_4_11.txt TLE 2134 ms 620680 KB
subtask_4_12.txt TLE 2134 ms 620680 KB
subtask_4_13.txt TLE 2134 ms 620680 KB
subtask_4_2.txt TLE 2134 ms 620680 KB
subtask_4_3.txt TLE 2134 ms 620680 KB
subtask_4_4.txt TLE 2134 ms 620680 KB
subtask_4_5.txt TLE 2129 ms 526352 KB
subtask_4_6.txt AC 634 ms 52296 KB
subtask_4_7.txt TLE 2119 ms 329368 KB
subtask_4_8.txt TLE 2134 ms 620680 KB
subtask_4_9.txt TLE 2117 ms 276000 KB