結果
| 問題 |
No.3114 0→1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 03:11:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,035 bytes |
| コンパイル時間 | 2,205 ms |
| コンパイル使用メモリ | 195,728 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-04-19 03:11:17 |
| 合計ジャッジ時間 | 3,723 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <typename T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <typename T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
struct IOST {
IOST() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
}
} IOST;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
vector<pair<char, int>> vp;
{
char bf = s[0];
int ct = 0;
for (char c : s) {
if (c == bf) ct++;
else {
vp.push_back({bf, ct});
ct = 1;
bf = c;
}
}
vp.push_back({bf, ct});
}
ll ans = 0;
int bfct = 1;
for (auto [c, ct] : vp) {
if (c == '0') {
ct--;
if (bfct) {
ans += (ct / 3) * 2 + (ct) % 3;
} else {
ct--;
ans += (ct / 3) * 2 + (ct) % 3 + 1;
}
} else bfct = (ct > 1);
}
cout << ans << "\n";
}
int main() {
int t = 1;
// cin >> t;
rep(i, 0, t) solve();
}