Runtime Error
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 = 1000005;
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:38:32
- Judged At
- 2024-12-17 11:34:23
- Judged By
- Score
- 0
- Total Time
- 5ms
- Peak Memory
- 4.363 MiB