Submission #44773

#TimeUsernameProblemLanguageResultExecution timeMemory
44773choikiwonSkyline (IZhO11_skyline)C++17
0 / 100
2073 ms48968 KiB
#include<bits/stdc++.h> using namespace std; int N; int H[302]; int cc[302][202][202]; int dp(int n, int c1, int c2) { if(n == N) return 0; int &ret = cc[n][c1][c2]; if(ret != -1) return ret; ret = 1e9; int add = c1 > c2? (c1 - c2) * 3 : 0; for(int i = 0; i <= min(min(c1, c2), H[n + 2]); i++) { int j = min(c1, c2) - i; ret = min(ret, add + 7 * i + 5 * j + dp(n + 1, c2 - i - j, H[n + 2] - i)); } return ret; } int main() { scanf("%d", &N); for(int i = 0; i < N; i++) { scanf("%d", &H[i]); } memset(cc, -1, sizeof(cc)); printf("%d", dp(0, H[0], H[1])); }

Compilation message (stderr)

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