Submission #1606552
Source Code Expand
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Text; class Simple { int N; int[] a; const int INF = 1234567890; void Solve() { //input N = io.Int; a = new int[N]; for (int i = 0; i < N; ++i) a[i] = io.Int; //cal int[] dp = new int[N]; for (int i = 0; i < N; ++i) dp[i] = INF; dp[0] = 0; dp[1] = Math.Abs(a[1] - a[0]); for (int i = 2; i < N; ++i) dp[i] = Math.Min(dp[i - 2] + Math.Abs(a[i] - a[i - 2]), dp[i - 1] + Math.Abs(a[i] - a[i - 1])); //ret Console.WriteLine(dp[N - 1]); } SimpleIO io = new SimpleIO(); public static void Main(string[] args) { new Simple().Stream(); } void Stream() { Solve(); io.writeFlush(); } } class SimpleIO { string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' }; StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; public SimpleIO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); } public string Next() { if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); BufferCnt = 0; return nextBuffer[BufferCnt++]; } public string String => Next(); public char Char => char.Parse(String); public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public void writeFlush() { Console.Out.Flush(); } }
Submission Info
Submission Time | |
---|---|
Task | C - 柱柱柱柱柱 |
User | rui0422 |
Language | C# (Mono 4.6.2.0) |
Score | 100 |
Code Size | 1956 Byte |
Status | AC |
Exec Time | 54 ms |
Memory | 18912 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 23 ms | 9300 KB |
sample_02.txt | AC | 21 ms | 11092 KB |
sample_03.txt | AC | 21 ms | 11092 KB |
subtask1_01.txt | AC | 21 ms | 9044 KB |
subtask1_02.txt | AC | 20 ms | 9044 KB |
subtask1_03.txt | AC | 21 ms | 9172 KB |
subtask1_04.txt | AC | 54 ms | 16864 KB |
subtask1_05.txt | AC | 52 ms | 14816 KB |
subtask1_06.txt | AC | 53 ms | 16864 KB |
subtask1_07.txt | AC | 54 ms | 18912 KB |