結果
問題 | No.921 ずんだアロー |
ユーザー |
![]() |
提出日時 | 2021-04-23 07:14:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 3,740 ms |
コンパイル使用メモリ | 103,552 KB |
実行使用メモリ | 25,344 KB |
最終ジャッジ日時 | 2024-07-04 06:54:42 |
合計ジャッジ時間 | 4,418 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); getAns(n, a); } static int calc (int n, int [] a, bool t) { var prez = t; var count = t ? 1 : 0; var pre = a[0]; for (int i = 1; i < n; i++) { if (a[i] == pre) { count++; prez = true; } else { if (prez) prez = false; else { prez = true; count++; } } pre = a[i]; } return count; } static void getAns(int n, int[] a) { var ans = Max(calc(n, a, true), calc(n, a, false)); Console.WriteLine(ans); } }