category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

1 state, dp, Fibonacci type

A. Boredom , Easy

code ```cpp int n; cin >> n; vector arr(n), freq(1e5 + 2, 0), dp(1e5 + 2, 0); ll limit = 0; for (auto &i : arr) { cin >> i; freq[i]++; limit = max(i, limit); } dp[1] = freq[1]; for (int i = 2; i <= limit; i++) { dp[i] = max(dp[i - 1], dp[i - 2] + i * freq[i]); } cout << dp[limit] << '\n'; ``` </details>