結果
問題 | No.1199 お菓子配り-2 |
ユーザー | Lily89164763 |
提出日時 | 2020-08-28 21:51:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 442 ms / 1,000 ms |
コード長 | 2,747 bytes |
コンパイル時間 | 3,552 ms |
コンパイル使用メモリ | 112,324 KB |
実行使用メモリ | 59,264 KB |
最終ジャッジ日時 | 2024-11-14 03:22:48 |
合計ジャッジ時間 | 18,622 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
27,144 KB |
testcase_01 | AC | 28 ms
25,388 KB |
testcase_02 | AC | 28 ms
24,964 KB |
testcase_03 | AC | 121 ms
41,892 KB |
testcase_04 | AC | 257 ms
48,528 KB |
testcase_05 | AC | 40 ms
27,852 KB |
testcase_06 | AC | 44 ms
28,056 KB |
testcase_07 | AC | 141 ms
46,832 KB |
testcase_08 | AC | 182 ms
46,220 KB |
testcase_09 | AC | 122 ms
41,912 KB |
testcase_10 | AC | 54 ms
30,820 KB |
testcase_11 | AC | 102 ms
38,676 KB |
testcase_12 | AC | 102 ms
39,056 KB |
testcase_13 | AC | 57 ms
32,180 KB |
testcase_14 | AC | 52 ms
31,716 KB |
testcase_15 | AC | 49 ms
32,000 KB |
testcase_16 | AC | 179 ms
47,336 KB |
testcase_17 | AC | 100 ms
37,640 KB |
testcase_18 | AC | 183 ms
47,436 KB |
testcase_19 | AC | 70 ms
32,108 KB |
testcase_20 | AC | 303 ms
50,604 KB |
testcase_21 | AC | 197 ms
47,964 KB |
testcase_22 | AC | 114 ms
32,868 KB |
testcase_23 | AC | 156 ms
41,908 KB |
testcase_24 | AC | 201 ms
49,092 KB |
testcase_25 | AC | 59 ms
34,096 KB |
testcase_26 | AC | 225 ms
46,252 KB |
testcase_27 | AC | 187 ms
46,864 KB |
testcase_28 | AC | 431 ms
57,324 KB |
testcase_29 | AC | 431 ms
57,112 KB |
testcase_30 | AC | 432 ms
54,948 KB |
testcase_31 | AC | 430 ms
55,000 KB |
testcase_32 | AC | 430 ms
55,124 KB |
testcase_33 | AC | 431 ms
57,044 KB |
testcase_34 | AC | 428 ms
57,544 KB |
testcase_35 | AC | 429 ms
57,176 KB |
testcase_36 | AC | 431 ms
55,296 KB |
testcase_37 | AC | 431 ms
55,208 KB |
testcase_38 | AC | 434 ms
55,248 KB |
testcase_39 | AC | 433 ms
55,092 KB |
testcase_40 | AC | 429 ms
55,412 KB |
testcase_41 | AC | 438 ms
57,224 KB |
testcase_42 | AC | 437 ms
55,168 KB |
testcase_43 | AC | 430 ms
55,568 KB |
testcase_44 | AC | 431 ms
54,968 KB |
testcase_45 | AC | 433 ms
55,212 KB |
testcase_46 | AC | 437 ms
57,268 KB |
testcase_47 | AC | 442 ms
59,264 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using CompLib.Util; public class Program { public void Solve() { var sc = new Scanner(); int n, m; var ln = Console.ReadLine().Split(' '); n = int.Parse(ln[0]); m = int.Parse(ln[1]); long[][] a = new long[n][]; for (int i = 0; i < n; i++) { a[i] = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } long[] s = new long[n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { s[i] += a[i][j]; } } long[] dp = new long[2]; dp[0] = 0; dp[1] = s[0]; for (int i = 1; i < n; i++) { var next = new long[2]; next[1] = Math.Max(dp[1], dp[0] + s[i]); next[0] = Math.Max(dp[0], dp[1] - s[i]); dp = next; } Console.WriteLine(Math.Max(dp[0], dp[1])); } public static void Main(string[] args) => new Program().Solve(); } namespace CompLib.Util { using System; using System.Linq; class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { if (_index >= _line.Length) { string s; do { s = Console.ReadLine(); } while (s.Length == 0); _line = s.Split(Separator); _index = 0; } return _line[_index++]; } public string ReadLine() { _index = _line.Length; return Console.ReadLine(); } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { string s = Console.ReadLine(); _line = s.Length == 0 ? new string[0] : s.Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }