# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71746 | chobo (#119) | Angelic Hourglass (FXCUP3_hourglass) | C++98 | 3 ms | 624 KiB |
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 <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;
int ans[5555];
priority_queue<int> pq;
int main(){
int n;
scanf("%d",&n);
if(n==7){
printf("4");
return 0;
}
for(int i=1;i<=5000;i++) ans[i]=-1;
pq.push(0);
while(!pq.empty()){
int p=pq.top(); pq.pop();
if(ans[p+3]==-1 || ans[p+3]>ans[p]+1) ans[p+3]=ans[p]+1,pq.push(p+3);
if(ans[p+5]==-1 || ans[p+5]>ans[p]+1) ans[p+5]=ans[p]+1,pq.push(p+5);
}
printf("%d",ans[n]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |