結果
問題 |
No.3114 0→1
|
ユーザー |
![]() |
提出日時 | 2025-04-20 19:32:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 432 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 67,412 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-20 19:32:40 |
合計ジャッジ時間 | 2,047 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<iostream> int f(const std::string&s,int n,int w){ int m=(w+1)/2,l=n+m-1,c=0,h=0; bool a[l],b[l]; for(int i=0;i<m-1;i++)a[i]=1; for(int i=m-1;i<l;i++)a[i]=s[i-m+1]=='1'; for(int i=0;i<l;i++)b[i]=a[i]; for(int i=0;i<w;i++)h+=a[i]; if(h<m){a[w-1]=1;h++;c++;} for(int i=1;i<l-w+1;i++){h-=a[i-1];h+=a[i+w-1];if(h<m){a[i+w-1]=1;h++;c++;}} return c; } int main(){ int x;std::string y; std::cin>>x>>y; std::cout<<f(y,x,3)<<'\n'; }