# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
898359 | devkudawla | Laugh Analysis (IOI16_laugh) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define ll int
int longest_laugh(string s){
ll n = s.size();
vector<ll> dp(n, 0);
if (s[0] == 'h' or s[0] == 'a')
dp[0] = 1;
ll answer = 0;
for (ll i = 1; i < n; i++)
{
if (s[i] == 'h' or s[i] == 'a')
{
dp[i] = 1;
if ((s[i] == 'h' and s[i - 1] == 'a') or (s[i] == 'a' and s[i - 1] == 'h'))
dp[i] = max(dp[i], dp[i - 1] + dp[i]);
}
answer = max(answer, dp[i]);
}
return answer;
}