Submission #1174452


Source Code Expand

using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    int N;
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        long[] T = new long[N];
        for(int i=0;i<N;i++){
            T[i] = int.Parse(str[i]);
        }
        int M = int.Parse(Console.ReadLine());
        for(int j=0;j<M;j++){
            str = Console.ReadLine().Split(' ');
            long originalT = T[int.Parse(str[0])-1];
            T[int.Parse(str[0])-1] = int.Parse(str[1]);
            long[] DP = new long[N];
            long[] sum = new long[N];
            sum[0] = T[0];
            for(int i=1;i<N;i++){
                sum[i] = sum[i-1] + T[i];
            }
            ConvexHullTrick Con = new ConvexHullTrick(N+1);
            Con.Add(-1,1);
            for(int i=0;i<N;i++){
                DP[i] = Math.Max(i == 0 ? 0 : DP[i-1],Con.Query(-i)-sum[i]+i*(i+1)/2);
                Con.Add(i,DP[i]+sum[i]+i*(i-1)/2);
            }
            sb.Append(DP[N-1]+"\n");
            T[int.Parse(str[0])-1] = originalT;
        }
    }
}

Submission Info

Submission Time
Task F - Contest with Drinks Hard
User leign
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1395 Byte
Status CE

Compile Error

./Main.cs(35,13): error CS0246: The type or namespace name `ConvexHullTrick' could not be found. Are you missing an assembly reference?
./Main.cs(36,13): error CS0841: A local variable `Con' cannot be used before it is declared
./Main.cs(38,55): error CS0841: A local variable `Con' cannot be used before it is declared
./Main.cs(39,17): error CS0841: A local variable `Con' cannot be used before it is declared