結果
| 問題 |
No.3114 0→1
|
| コンテスト | |
| ユーザー |
pengin_2000
|
| 提出日時 | 2025-04-18 20:52:58 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 342 bytes |
| コンパイル時間 | 302 ms |
| コンパイル使用メモリ | 25,088 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-18 20:53:01 |
| 合計ジャッジ時間 | 1,551 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 30 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%s", s);
| ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
char s[200005];
int main()
{
int n;
scanf("%d", &n);
scanf("%s", s);
int sum = 0, ans = 0, max = -1e9;
int i;
for (i = 0; i < n; i++)
{
if (s[i] == '0')
{
sum--;
if (sum - max < 0)
{
ans++;
sum += 2;
}
if (max < sum)
max = sum;
}
else
sum++;
}
printf("%d\n", ans);
return 0;
}
pengin_2000