Submission #71840

#TimeUsernameProblemLanguageResultExecution timeMemory
71840:p (#119)Angelic Hourglass (FXCUP3_hourglass)C++14
58 / 100
3 ms756 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...