結果
| 問題 | 
                            No.921 ずんだアロー
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 15:10:03 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 825 bytes | 
| コンパイル時間 | 345 ms | 
| コンパイル使用メモリ | 82,728 KB | 
| 実行使用メモリ | 100,864 KB | 
| 最終ジャッジ日時 | 2025-06-12 15:10:13 | 
| 合計ジャッジ時間 | 2,975 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 WA * 7 | 
ソースコード
n = int(input())
a = list(map(int, input().split()))
# Calculate the maximum frequency of any value in the array
from collections import defaultdict
count = defaultdict(int)
for num in a:
    count[num] += 1
max_freq = max(count.values()) if count else 0
# Calculate the maximum non-adjacent selection using dynamic programming
if n == 0:
    max_independent = 0
elif n == 1:
    max_independent = 1
else:
    prev_not = 0  # Represents not taking the previous element
    prev_yes = 1  # Represents taking the previous element
    for i in range(1, n):
        current_not = max(prev_not, prev_yes)
        current_yes = prev_not + 1
        prev_not, prev_yes = current_not, current_yes
    max_independent = max(prev_not, prev_yes)
# The answer is the maximum of the two strategies
print(max(max_freq, max_independent))
            
            
            
        
            
gew1fw