/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error 1ms 580.0 KiB
#2 Runtime Error 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
using ll = long long;

const int MX = 105;
int dp[MX];

int solve(int n) {
  if (n == 0) return 0;
  if (n < 2) return 100000;

  int& curr = dp[n];
  if (curr != -1) return curr;

  curr = 1 + min(solve(n-2), solve(n-3));

  return curr;
}

int main() {
  FAST;
  memset(dp, -1, sizeof(dp));
  
  int tc = 1, ti;
  cin >> tc;

  for (ti = 1; ti <= tc; ++ti) {
    int n;
    cin >> n;
    cout << solve(n) << "\n";
  }

  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:37:37
Judged At
2024-12-17 11:34:25
Judged By
Score
0
Total Time
1ms
Peak Memory
580.0 KiB