Submission #52140

#TimeUsernameProblemLanguageResultExecution timeMemory
52140ainta오렌지 출하 (JOI16_ho_t1)C++17
100 / 100
79 ms4080 KiB
#include<cstdio> #include<algorithm> using namespace std; int n, m, w[20100], K; long long D[20100]; int main() { int i, j; scanf("%d%d%lld", &n, &m,&K); for (i = 1; i <= n; i++) { scanf("%d", &w[i]); } for (i = 1; i <= n; i++) { D[i] = 1e18; int Mn = 2e9, Mx = -2e9; for (j = 1; j <= i&&j <= m; j++) { Mn = min(Mn, w[i - j + 1]); Mx = max(Mx, w[i - j + 1]); D[i] = min(D[i], D[i - j] + 1ll * j*(Mx - Mn) + K); } } printf("%lld\n", D[n]); }

Compilation message (stderr)

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:8:29: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
  scanf("%d%d%lld", &n, &m,&K);
                           ~~^
2016_ho_t1.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld", &n, &m,&K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &w[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...