結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
![]() |
提出日時 | 2025-07-25 21:25:13 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 651 bytes |
コンパイル時間 | 2,504 ms |
コンパイル使用メモリ | 77,280 KB |
実行使用メモリ | 53,004 KB |
最終ジャッジ日時 | 2025-07-25 21:25:47 |
合計ジャッジ時間 | 12,968 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 16 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] s = sc.next().toCharArray(); sc.close(); int[] a = new int[n + 1]; for (int i = 0; i < n; i++) { if (s[i] == '-') { a[i + 1]++; } a[i + 1] += a[i]; } int[] b = new int[n + 1]; for (int i = n - 1; i >= 0; i--) { if (s[i] == '+') { b[i]++; } b[i] += b[i + 1]; } int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') { int val = a[i] + 1 + b[i]; ans = Math.max(ans, val); } } System.out.println(ans); } }