Submission #924335

#TimeUsernameProblemLanguageResultExecution timeMemory
924335asdfGuestSkyline (IZhO11_skyline)C++14
0 / 100
1 ms500 KiB
#include <iostream> #include <algorithm> using namespace std; int n, a[10000 + 2] = {0}; inline int f(int idx, int len) { int m = 1000000000; for (int i = 0; i < len; i++) m = min(m, a[idx + i]); for (int i = 0; i < len; i++) a[idx + i] -= m; return m; } int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); int cost = 0; for (int i = 0; i < n; i++) { if (a[i] <= a[i + 2] && a[i + 1] > a[i + 2]) { int m = a[i + 0] - a[i + 1] + a[i + 2]; a[i] -= m; a[i + 1] -= m; a[i + 2] -= m; cost += 7 * m; cost += 5 * f(i, 2); } cost += 7 * f(i, 3); cost += 5 * f(i, 2); cost += 3 * f(i, 1); } printf("%d\n", cost); system("pause"); return 0; }

Compilation message (stderr)

skyline.cpp: In function 'int main()':
skyline.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
skyline.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
skyline.cpp:47:11: warning: ignoring return value of 'int system(const char*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     system("pause");
      |     ~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...