Accepted
Code
#include<bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define endl '\n'
#define ll long long
#define test_case int t;cin>>t;while(t--)
const int mx=2e5+123;
long long dp[mx];
int fun(int n){
if(n==0) return 0;
if(n<0) return 1e9;
if(dp[n]!=-1) return dp[n];
int m1,m2;
m1=fun(n-2)+1;
m2=fun(n-3)+1;
dp[n]=min(m1,m2);
return dp[n];
}
int main(){
FAST_IO;
memset(dp,-1,sizeof(dp));
int n;
cin>>n;
cout<<fun(n);
}
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 15:43:06
- Judged At
- 2024-12-17 11:36:15
- Judged By
- Score
- 100
- Total Time
- 3ms
- Peak Memory
- 2.066 MiB