結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
![]() |
提出日時 | 2017-01-13 10:22:09 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 3,885 bytes |
コンパイル時間 | 1,098 ms |
コンパイル使用メモリ | 115,316 KB |
実行使用メモリ | 26,456 KB |
最終ジャッジ日時 | 2024-12-31 11:25:34 |
合計ジャッジ時間 | 3,141 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; using System.IO; class Program { static private Magatro M = new Magatro(); static private void Main(string[]args) { M.Scan(); M.Solve(); } } public class Scanner { private string[] S; private int Index; private char Separator; public Scanner(char separator = ' ') { Index = 0; Separator = separator; S = new string[0]; } private string[] Line() { return Console.ReadLine().Split(Separator); } public string Next() { string result; if (Index >= S.Length) { S = Line(); Index = 0; } result = S[Index]; Index++; return result; } public int NextInt() { return int.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } } public class Magatro { private int Nw, Nb; private int[] W, B; public void Scan() { Scanner sc = new Scanner(); Nw = sc.NextInt(); W = new int[Nw]; for(int i = 0; i < Nw; i++) { W[i] = sc.NextInt(); } Nb = sc.NextInt(); B = new int[Nb]; for(int i = 0; i < Nb; i++) { B[i] = sc.NextInt(); } } public void Solve() { int ans; int black, white; Array.Sort(W,(a,b)=>-a.CompareTo(b)); Array.Sort(B,(a,b)=>-a.CompareTo(b)); int type = 0; white = 1; int block = W[0]; bool flag; while (true) { if (type == 0) { type = 1; flag = false; for (int i = 0; i < Nb; i++) { if (block > B[i]) { block = B[i]; white++; flag = true; break; } } if (flag) continue; break; } else { type = 0; flag = false; for (int i = 0; i < Nw; i++) { if (block > W[i]) { block = W[i]; white++; flag = true; break; } } if (flag) continue; break; } } black = 1; type = 1; block = B[0]; while (true) { if (type == 0) { type = 1; flag = false; for (int i = 0; i < Nb; i++) { if (block > B[i]) { block = B[i]; black++; flag = true; break; } } if (flag) continue; break; } else { type = 0; flag = false; for (int i = 0; i < Nw; i++) { if (block > W[i]) { block = W[i]; black++; flag = true; break; } } if (flag) continue; break; } } Console.WriteLine(Math.Max(black, white)); } }