Submission #71740

# Submission time Handle Problem Language Result Execution time Memory
71740 2018-08-25T13:59:27 Z chobo(#2238, andy627) Angelic Hourglass (FXCUP3_hourglass) C++
58 / 100
4 ms 760 KB
#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==17){
        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

hourglass.cpp: In function 'int main()':
hourglass.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 564 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 3 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 3 ms 700 KB Output is correct
3 Correct 4 ms 564 KB Output is correct
4 Correct 3 ms 700 KB Output is correct
5 Correct 3 ms 700 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 3 ms 700 KB Output is correct
9 Incorrect 2 ms 700 KB Output isn't correct
10 Correct 3 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 3 ms 700 KB Output is correct
13 Correct 3 ms 700 KB Output is correct
14 Correct 2 ms 700 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Incorrect 2 ms 700 KB Output isn't correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 700 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
4 Correct 3 ms 700 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 4 ms 700 KB Output is correct
8 Correct 3 ms 700 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 2 ms 700 KB Output is correct
11 Correct 3 ms 760 KB Output is correct
12 Correct 3 ms 700 KB Output is correct