Submission #703056

#TimeUsernameProblemLanguageResultExecution timeMemory
703056rainboySkyline (IZhO11_skyline)C11
100 / 100
83 ms604 KiB
#include <stdio.h> #include <string.h> #define N 302 #define A 200 #define INF 0x3f3f3f3f int min(int a, int b) { return a < b ? a : b; } int main() { static int aa[N], dp[A + 1][A + 1], dq[A + 1][A + 1]; int n, i, a, b; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); n += 2; for (a = 0; a <= A; a++) memset(dp[a], 0x3f, (A + 1) * sizeof *dp[a]); dp[0][0] = 0; for (i = 0; i < n; i++) { for (a = 0; a <= A; a++) memset(dq[a], 0x3f, (A + 1) * sizeof *dq[a]); for (a = 0; a <= A; a++) for (b = 0; b <= A; b++) { int x = dp[a][b]; if (x == INF || b < a || aa[i] < a) continue; dq[b - a][aa[i] - a] = min(dq[b - a][aa[i] - a], x + a * 7); } for (a = A; a >= 0; a--) for (b = A; b >= 0; b--) { int x = dq[a][b]; if (x == INF) continue; if (b > 0) { dq[a][b - 1] = min(dq[a][b - 1], dq[a][b] + 3); if (a > 0) dq[a - 1][b - 1] = min(dq[a - 1][b - 1], dq[a][b] + 5); } } for (a = 0; a <= A; a++) memcpy(dp[a], dq[a], (A + 1) * sizeof *dp[a]); } printf("%d\n", dp[0][0]); return 0; }

Compilation message (stderr)

skyline.c: In function 'main':
skyline.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
skyline.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...