結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-16 19:33:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 1,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 733 ms |
| コンパイル使用メモリ | 71,364 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 02:30:22 |
| 合計ジャッジ時間 | 1,398 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
using namespace std;
string s;
main()
{
cin>>s;
s+="00";
vector<int>T;
int cnt=1;
for(int i=1;i<s.size();i++)
{
if(s[i-1]!=s[i])
{
T.push_back(cnt);
cnt=1;
}
else cnt++;
}
T.push_back(cnt);
int ans=0;
for(int i=0;i<T.size();i+=2)
{
int cnt=0;
bool flag=T[i]>1;
while(i+2<T.size()&&T[i+1]==1)
{
cnt++;
i+=2;
flag|=T[i]>1;
}
ans+=flag?cnt+2:cnt+1;
}
cout<<ans<<endl;
}