/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error foo: foo.cc:32: int main(): Assertion `(2 <= n) && (n <= 100)' failed. 5ms 4.52 MiB
#2 Runtime Error foo: foo.cc:32: int main(): Assertion `(2 <= n) && (n <= 100)' failed. 5ms 4.375 MiB
#3 Runtime Error foo: foo.cc:32: int main(): Assertion `(2 <= n) && (n <= 100)' failed. 4ms 4.27 MiB
#4 Runtime Error foo: foo.cc:32: int main(): Assertion `(2 <= n) && (n <= 100)' failed. 5ms 4.316 MiB

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;
    assert((2 <= n) && (n <= 100));
    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:58
Judged At
2024-10-03 16:38:58
Judged By
Score
0
Total Time
5ms
Peak Memory
4.52 MiB