結果
問題 |
No.3114 0→1
|
ユーザー |
![]() |
提出日時 | 2025-04-20 19:37:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 392 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 28,032 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-20 19:37:07 |
合計ジャッジ時間 | 1,526 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d%s",&N,S); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio> const int M=1000010; char S[M]; char A[M]; int main(){ int N,a,b,c,d,e,f,g; scanf("%d%s",&N,S); a=3; b=(a+1)/2; c=N+b-1; d=0; e=0; for(f=0;f<c;f++)A[f]=(f<b-1)||S[f-b+1]=='1'; for(f=0;f<a;f++)e+=A[f]; if(e<b)A[a-1]=1,e++,d++; for(f=1;f<=c-a;f++){ g=f+a-1; e-=A[f-1]; e+=A[g]; if(e<b)A[g]=1,e++,d++; } printf("%d\n",d); return 0; }