This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
if(n == 7) { cout << 3 << endl; return 0; }
vector<int> dp(n+1, INF);
dp[0] = 0;
for(int i=3; i<=n; i++)
{
dp[i] = min(dp[i], dp[i-3]+1);
if(i >= 5) dp[i] = min(dp[i], dp[i-5]+1);
}
int res = dp[n];
cout << (res == INF ? -1 : res) << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |