結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
![]() |
提出日時 | 2025-07-25 21:26:21 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 504 bytes |
コンパイル時間 | 1,196 ms |
コンパイル使用メモリ | 26,320 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-25 21:26:25 |
合計ジャッジ時間 | 1,632 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%s", s); | ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> char s[300005]; int cnt[300005][2]; int main() { int n; scanf("%d", &n); int i; scanf("%s", s); cnt[0][0] = cnt[0][1] = 0; for (i = 0; i < n; i++) { cnt[i + 1][0] = cnt[i][0]; cnt[i + 1][1] = cnt[i][1]; if (s[i] == '-') cnt[i + 1][0]++; else if (s[i] == '+') cnt[i + 1][1]++; } int ans = 1; for (i = 0; i < n; i++) { if (ans < cnt[i][0] + cnt[n][1] - cnt[i + 1][1] + 1) ans = cnt[i][0] + cnt[n][1] - cnt[i + 1][1] + 1; } printf("%d\n", ans); return 0; }