結果
問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
ユーザー | kakel-san |
提出日時 | 2024-08-08 23:19:09 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 960 ms / 2,000 ms |
コード長 | 5,064 bytes |
コンパイル時間 | 8,035 ms |
コンパイル使用メモリ | 169,896 KB |
実行使用メモリ | 188,840 KB |
最終ジャッジ日時 | 2024-08-08 23:19:49 |
合計ジャッジ時間 | 36,583 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 62 ms
31,096 KB |
testcase_01 | AC | 61 ms
30,976 KB |
testcase_02 | AC | 61 ms
31,232 KB |
testcase_03 | AC | 61 ms
31,488 KB |
testcase_04 | AC | 62 ms
31,104 KB |
testcase_05 | AC | 63 ms
31,616 KB |
testcase_06 | AC | 63 ms
31,488 KB |
testcase_07 | AC | 62 ms
31,232 KB |
testcase_08 | AC | 73 ms
34,048 KB |
testcase_09 | AC | 73 ms
34,176 KB |
testcase_10 | AC | 72 ms
34,304 KB |
testcase_11 | AC | 73 ms
33,920 KB |
testcase_12 | AC | 72 ms
34,176 KB |
testcase_13 | AC | 75 ms
33,920 KB |
testcase_14 | AC | 70 ms
34,176 KB |
testcase_15 | AC | 75 ms
34,304 KB |
testcase_16 | AC | 72 ms
33,784 KB |
testcase_17 | AC | 73 ms
34,304 KB |
testcase_18 | AC | 117 ms
36,344 KB |
testcase_19 | AC | 87 ms
34,944 KB |
testcase_20 | AC | 112 ms
36,336 KB |
testcase_21 | AC | 96 ms
35,696 KB |
testcase_22 | AC | 99 ms
35,840 KB |
testcase_23 | AC | 112 ms
36,224 KB |
testcase_24 | AC | 112 ms
36,352 KB |
testcase_25 | AC | 111 ms
36,480 KB |
testcase_26 | AC | 114 ms
36,992 KB |
testcase_27 | AC | 99 ms
35,712 KB |
testcase_28 | AC | 399 ms
49,136 KB |
testcase_29 | AC | 345 ms
44,504 KB |
testcase_30 | AC | 309 ms
43,776 KB |
testcase_31 | AC | 394 ms
50,304 KB |
testcase_32 | AC | 497 ms
58,496 KB |
testcase_33 | AC | 306 ms
44,032 KB |
testcase_34 | AC | 455 ms
52,096 KB |
testcase_35 | AC | 488 ms
51,072 KB |
testcase_36 | AC | 690 ms
60,800 KB |
testcase_37 | AC | 236 ms
42,752 KB |
testcase_38 | AC | 377 ms
47,488 KB |
testcase_39 | AC | 266 ms
43,008 KB |
testcase_40 | AC | 323 ms
44,672 KB |
testcase_41 | AC | 447 ms
49,664 KB |
testcase_42 | AC | 643 ms
60,160 KB |
testcase_43 | AC | 423 ms
49,792 KB |
testcase_44 | AC | 499 ms
50,048 KB |
testcase_45 | AC | 400 ms
45,568 KB |
testcase_46 | AC | 488 ms
52,340 KB |
testcase_47 | AC | 283 ms
44,160 KB |
testcase_48 | AC | 758 ms
70,652 KB |
testcase_49 | AC | 628 ms
70,400 KB |
testcase_50 | AC | 772 ms
70,656 KB |
testcase_51 | AC | 677 ms
70,400 KB |
testcase_52 | AC | 746 ms
70,656 KB |
testcase_53 | AC | 917 ms
67,840 KB |
testcase_54 | AC | 891 ms
67,968 KB |
testcase_55 | AC | 960 ms
67,696 KB |
testcase_56 | AC | 902 ms
68,096 KB |
testcase_57 | AC | 745 ms
67,840 KB |
testcase_58 | AC | 585 ms
88,576 KB |
testcase_59 | AC | 583 ms
86,260 KB |
testcase_60 | AC | 591 ms
85,876 KB |
testcase_61 | AC | 589 ms
88,576 KB |
testcase_62 | AC | 595 ms
86,012 KB |
testcase_63 | AC | 87 ms
58,624 KB |
testcase_64 | AC | 86 ms
58,752 KB |
testcase_65 | AC | 88 ms
58,752 KB |
testcase_66 | AC | 89 ms
58,240 KB |
testcase_67 | AC | 88 ms
58,368 KB |
testcase_68 | AC | 60 ms
31,360 KB |
testcase_69 | AC | 59 ms
31,232 KB |
testcase_70 | AC | 60 ms
31,488 KB |
testcase_71 | AC | 59 ms
31,488 KB |
testcase_72 | AC | 58 ms
30,848 KB |
testcase_73 | AC | 57 ms
188,840 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (98 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/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (k, l, m, n, s) = (c[0], c[1], c[2], c[3], c[4]); var a = NList; var b = NList; c = NList; var d = NList; var q = Qua(k, l, m, n, s, a, b, c, d); WriteLine(q.t); WriteLine(q.ans); } static (long t, string ans) Qua(long k, long l, long m, long n, long s, long[] a, long[] b, long[] c, long[] d) { var firstp = new List<(long a, long b, long x)>(); var firstn = new List<(long a, long b, long x)>(); var firstz = new List<(long a, long b)>(); for (var i = 0; i < k; ++i) for (var j = 0; j < l; ++j) { if (a[i] * b[j] > 0) firstp.Add((a[i], b[j], a[i] * b[j])); else if (a[i] * b[j] < 0) firstn.Add((a[i], b[j], a[i] * b[j])); else firstz.Add((a[i], b[j])); } var secondp = new List<(long c, long d, long x)>(); var secondn = new List<(long c, long d, long x)>(); var secondz = new List<(long c, long d)>(); for (var i = 0; i < m; ++i) for (var j = 0; j < n; ++j) { if (c[i] * d[j] > 0) secondp.Add((c[i], d[j], c[i] * d[j])); else if (c[i] * d[j] < 0) secondn.Add((c[i], d[j], c[i] * d[j])); else secondz.Add((c[i], d[j])); } firstp.Sort((l, r) => l.x.CompareTo(r.x)); firstn.Sort((l, r) => r.x.CompareTo(l.x)); secondp.Sort((l, r) => l.x.CompareTo(r.x)); secondn.Sort((l, r) => r.x.CompareTo(l.x)); var ok = -1_000_000_000_000_000_000; var ng = 1_000_000_000_000_000_000; var ans = ""; while (ng - ok > 1) { var sub = ""; var mid = (ok + ng) / 2; // Tよりも小さいABCDの数が S-1 個以下となる最大の数を求める var count = 0L; if (mid < 0) { var cur = secondn.Count - 1; for (var i = 0; i < firstp.Count; ++i) { while (cur >= 0 && firstp[i].x * secondn[cur].x < mid) --cur; count += secondn.Count - 1 - cur; if (cur >= 0 && firstp[i].x * secondn[cur].x == mid) { sub = $"{firstp[i].a} {firstp[i].b} {secondn[cur].c} {secondn[cur].d}"; } } cur = secondp.Count - 1; for (var i = 0; i < firstn.Count; ++i) { while (cur >= 0 && firstn[i].x * secondp[cur].x < mid) --cur; count += secondp.Count - 1 - cur; if (cur >= 0 && firstn[i].x * secondp[cur].x == mid) { sub = $"{firstn[i].a} {firstn[i].b} {secondp[cur].c} {secondp[cur].d}"; } } } else if (mid > 0) { count += firstp.Count * ((long)secondn.Count + secondz.Count) + firstn.Count * ((long)secondp.Count + secondz.Count) + firstz.Count * ((long)secondp.Count + secondn.Count + secondz.Count); var cur = 0; for (var i = firstp.Count - 1; i >= 0; --i) { while (cur < secondp.Count && firstp[i].x * secondp[cur].x < mid) ++cur; count += cur; if (cur < secondp.Count && firstp[i].x * secondp[cur].x == mid) { sub = $"{firstp[i].a} {firstp[i].b} {secondp[cur].c} {secondp[cur].d}"; } } cur = 0; for (var i = firstn.Count - 1; i >= 0; --i) { while (cur < secondn.Count && firstn[i].x * secondn[cur].x < mid) ++cur; count += cur; if (cur < secondn.Count && firstn[i].x * secondn[cur].x == mid) { sub = $"{firstn[i].a} {firstn[i].b} {secondn[cur].c} {secondn[cur].d}"; } } } else { count += (long)firstp.Count * secondn.Count + (long)firstn.Count * secondp.Count; if (firstz.Count > 0) sub = $"{firstz[0].a} {firstz[0].b} {c[0]} {d[0]}"; else if (secondz.Count > 0) sub = $"{a[0]} {b[0]} {secondz[0].c} {secondz[0].d}"; } if (count <= s - 1) { ok = mid; ans = sub; } else ng = mid; } return (ok, ans); } }