結果
問題 |
No.3114 0→1
|
ユーザー |
![]() |
提出日時 | 2025-04-20 19:36:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 399 bytes |
コンパイル時間 | 868 ms |
コンパイル使用メモリ | 68,268 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-20 19:36:28 |
合計ジャッジ時間 | 2,208 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<iostream> int A(const std::string&x,int y,int z){ int a=(z+1)/2,b=y+a-1,c=0,d=0; char e[b]; const char*f=x.c_str(); for(int i=0;i<b;i++)e[i]=(i<a-1)||f[i-a+1]=='1'; for(int i=0;i<z;i++)d+=e[i]; if(d<a)e[z-1]=1,d++,c++; for(int i=1,j;i<b-z+1;i++){ j=i+z-1; d-=e[i-1];d+=e[j]; if(d<a)e[j]=1,d++,c++; } return c; } int main(){ int a;std::string b; std::cin>>a>>b; std::cout<<A(b,a,3)<<'\n'; }