Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
const int inf = INT32_MAX;
int dp[200];
int f(int n){
if(n == 0) return 0;
if(n < 0) return inf;
if (dp[n] != -1) return dp[n];
int x = 0;
int y = 0;
if(n >= 2) x = 1 + f(n - 2);
if(n >= 3) y = 1 + f(n - 3);
int res = min(x, y);
dp[n] = res;
return dp[n];
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
memset(dp, -1, sizeof(dp));
int ans = f(n);
cout << ans;
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1106 too easy or three easy
- Contest
- Brain Booster #6
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-03 16:10:30
- Judged At
- 2024-12-17 11:35:18
- Judged By
- Score
- 10
- Total Time
- 1ms
- Peak Memory
- 536.0 KiB