/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 2ms 328.0 KiB
#2 Wrong Answer 3ms 472.0 KiB

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 = INT32_MAX;
  int y = INT32_MAX;

  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:13:14
Judged At
2024-11-11 02:49:01
Judged By
Score
0
Total Time
3ms
Peak Memory
472.0 KiB