結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-18 23:03:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 462 bytes |
コンパイル時間 | 1,710 ms |
コンパイル使用メモリ | 192,992 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-18 23:03:43 |
合計ジャッジ時間 | 2,768 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s; cin >> s; s = "." + s; int ans = 0; for(int i = 3; i <= n; i++) { int cnt = (s[i - 2] == '0') + (s[i - 1] == '0') + (s[i] == '0'); if (cnt == 3) { s[i - 1] = '1'; s[i] = '1'; ans += 2; } else if (cnt == 2) { if (s[i] == '0') { s[i] = '1'; ans++; } else if (s[i - 1] == '0') { s[i - 1] = '1'; ans++; } } } cout << ans; }