結果
問題 | No.2510 Six Cube Sum Counting |
ユーザー | crimsontea |
提出日時 | 2023-10-20 22:58:23 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 1,557 ms / 4,000 ms |
コード長 | 3,975 bytes |
コンパイル時間 | 16,964 ms |
コンパイル使用メモリ | 167,960 KB |
実行使用メモリ | 261,620 KB |
最終ジャッジ日時 | 2024-09-20 21:23:17 |
合計ジャッジ時間 | 57,906 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,415 ms
101,684 KB |
testcase_01 | AC | 1,406 ms
102,124 KB |
testcase_02 | AC | 1,486 ms
101,940 KB |
testcase_03 | AC | 1,455 ms
102,400 KB |
testcase_04 | AC | 1,415 ms
102,016 KB |
testcase_05 | AC | 1,414 ms
102,068 KB |
testcase_06 | AC | 1,557 ms
101,940 KB |
testcase_07 | AC | 1,442 ms
102,144 KB |
testcase_08 | AC | 1,438 ms
102,272 KB |
testcase_09 | AC | 1,425 ms
101,936 KB |
testcase_10 | AC | 1,441 ms
102,196 KB |
testcase_11 | AC | 1,439 ms
101,888 KB |
testcase_12 | AC | 1,438 ms
101,812 KB |
testcase_13 | AC | 1,451 ms
102,016 KB |
testcase_14 | AC | 1,447 ms
102,076 KB |
testcase_15 | AC | 1,429 ms
102,200 KB |
testcase_16 | AC | 1,428 ms
102,196 KB |
testcase_17 | AC | 1,448 ms
102,196 KB |
testcase_18 | AC | 1,457 ms
102,016 KB |
testcase_19 | AC | 1,438 ms
101,940 KB |
testcase_20 | AC | 1,457 ms
101,864 KB |
testcase_21 | AC | 1,463 ms
101,760 KB |
testcase_22 | AC | 1,468 ms
102,016 KB |
testcase_23 | AC | 1,446 ms
102,124 KB |
testcase_24 | AC | 1,485 ms
102,192 KB |
testcase_25 | AC | 1,424 ms
102,144 KB |
testcase_26 | AC | 1,429 ms
101,940 KB |
testcase_27 | AC | 1,471 ms
102,072 KB |
testcase_28 | AC | 1,473 ms
101,688 KB |
testcase_29 | AC | 1,473 ms
261,620 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (134 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
#nullable enable using System; using System.Linq; using System.Collections; using System.IO; using System.Collections.Generic; using System.Text; using System.Numerics; using System.Runtime.Intrinsics.X86; using System.Buffers; using System.Diagnostics; using System.Runtime.CompilerServices; using static InputUtility; using System.Reflection; class Program { static void Main() { InputNewLine(); var x = NextInt32; Stopwatch sw = Stopwatch.StartNew(); var abc = Abc(); static (int v, int c)[] Abc() { Span<int> n3 = stackalloc int[301]; for (int i = 0; i < n3.Length; i++) { n3[i] = i * i * i; } (int v, int c)[] abc = new (int v, int c)[4590551]; int index = 0; for (int a = 0; a < n3.Length; a++) { for (int b = a; b < n3.Length; b++) { for (int c = b; c < n3.Length; c++) { abc[index++] = (n3[a] + n3[b] + n3[c], c); } } } return abc; } Array.Sort(abc); var def = Def(); static (int v, int d)[] Def() { Span<int> n3 = stackalloc int[301]; for (int i = 0; i < n3.Length; i++) { n3[i] = i * i * i; } (int v, int c)[] abc = new (int v, int c)[4590551]; int index = 0; for (int a = 0; a < n3.Length; a++) { for (int b = a; b < n3.Length; b++) { for (int c = b; c < n3.Length; c++) { abc[index++] = (n3[a] + n3[b] + n3[c], a); } } } return abc; } Array.Sort(def); int res = 0; int right = def.Length - 1; foreach (var (v, c) in abc) { var target = x - v; if (target < 0) { break; } while (right >= 0 && target < def[right].v) { right--; } for (int i = right; i >= 0; i--) { if (target != def[i].v) { break; } if (c <= def[i].d) { res++; } else { break; } } } Console.WriteLine(res); } } public static class InputUtility { private static string[]? s_inputs; private static string? s_raw; private static int s_index = 0; private static void Init() => s_index = 0; public static int NextInt32 => int.Parse(s_inputs![s_index++]!); public static uint NextUInt32 => uint.Parse(s_inputs![s_index++]!); public static long NextInt64 => long.Parse(s_inputs![s_index++]!); public static string NextString => s_inputs![s_index++]; public static char NextChar => s_inputs![s_index++][0]; public static int[] GetInt32Array() => s_inputs!.Select(int.Parse).ToArray(); public static long[] GetInt64Array() => s_inputs!.Select(long.Parse).ToArray(); public static string GetRawString() => s_raw!; #if DEBUG private static TextReader? s_textReader; public static void SetSource(string path) => s_textReader = new StringReader(File.ReadAllText(path)); #endif public static bool InputNewLine() { #if DEBUG if (s_textReader is TextReader sr) { Init(); s_raw = sr.ReadLine()!; s_inputs = s_raw.Split(' ', StringSplitOptions.RemoveEmptyEntries); return true; } #endif Init(); s_raw = Console.ReadLine()!; s_inputs = s_raw.Split(' ', StringSplitOptions.RemoveEmptyEntries); return true; } }