結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-13 21:57:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 657 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 74,012 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 04:13:32 |
| 合計ジャッジ時間 | 1,208 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
string s;
cin >> s;
int n = s.length();
vector<int> v;
for(int i = 0; i < n;){
char c = s[i];
int cnt = 1;
while(i+1 < n && c == s[i+1]) cnt++, i++;
i++;
v.push_back(cnt);
}
int ans = 0;
for(int i = 0; i < v.size();){
bool notone = v[i] != 1;
int cnt = 1;
i += 2;
while(i < v.size() && v[i-1] == 1){
cnt++;
notone |= (v[i] != 1);
i += 2;
}
ans += cnt + (notone);
}
cout << ans << endl;
return 0;
}