結果
問題 |
No.647 明太子
|
ユーザー |
![]() |
提出日時 | 2018-09-08 15:31:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 164 ms / 4,500 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 1,035 ms |
コンパイル使用メモリ | 112,620 KB |
実行使用メモリ | 21,248 KB |
最終ジャッジ日時 | 2024-12-16 06:53:40 |
合計ジャッジ時間 | 3,175 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq; using System.Collections.Generic; using System; public class P { public int x { get; set; } public int y { get; set; } public int id { get; set; } } public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var a = new int[n, 2]; for (int i = 0; i < n; i++) { string[] line = Console.ReadLine().Trim().Split(' '); a[i, 0] = int.Parse(line[0]); a[i, 1] = int.Parse(line[1]); } var m = int.Parse(Console.ReadLine().Trim()); var ps = new P[m]; for (int i = 0; i < m; i++) { string[] line = Console.ReadLine().Trim().Split(' '); var x = int.Parse(line[0]); var y = int.Parse(line[1]); ps[i] = new P { id = i, x = x, y = y }; } var ps2 = ps.OrderBy(z => z.x).ToArray(); printAns(a, ps2); } public static void printAns(int[,] a, P[] b) { var ans = new List<int>(); var n = a.GetLength(0); var m = b.Length; var buy = new int[m]; var max = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { if (b[j].x > a[i, 0]) break; if (b[j].y >= a[i, 1]) { buy[b[j].id]++; max = Math.Max(max, buy[b[j].id]); } } if (max == 0) { Console.WriteLine(0); return; } for (int i = 0; i < m; i++) if (buy[i] == max) Console.WriteLine(i + 1); } }