Submission #62586

#TimeUsernameProblemLanguageResultExecution timeMemory
62586imsifileAngelic Hourglass (FXCUP3_hourglass)C++14
100 / 100
4 ms1256 KiB
#include<stdio.h> int N, dy[5050][4][6]; int mins(int a, int b){ if(!a) return b; if(!b) return a; return a<b?a:b; } int sub(int a, int b){ return a<b?0:a-b; } int getdy(int t, int h1, int h2){ if(t == 0) return 0; if(t < 0) return 9999; if(dy[t][h1][h2]) return dy[t][h1][h2]; int dap = 9999, gap; if(h1 == 0){ gap = getdy(t, 3, h2) + 1; if(dap > gap) dap = gap; if(0 < h2 && h2 < 5){ gap = getdy(t, 3, 5-h2) + 1; if(dap > gap) dap = gap; } } if(h2 == 0){ gap = getdy(t, h1, 5) + 1; if(dap > gap) dap = gap; if(0 < h1 && h1 < 3){ gap = getdy(t, 3-h1, 5) + 1; if(dap > gap) dap = gap; } } int m = mins(h1, h2); if(m){ gap = getdy(t-m, sub(h1,m), sub(h2,m)); if(dap > gap) dap = gap; } return dy[t][h1][h2] = dap; } int main(){ scanf("%d", &N); int v = getdy(N,0,0); printf("%d\n", v == 9999 ? -1 : v); return 0; }

Compilation message (stderr)

hourglass.cpp: In function 'int main()':
hourglass.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...