제출 #51656

#제출 시각아이디문제언어결과실행 시간메모리
51656gs13105오렌지 출하 (JOI16_ho_t1)C++17
100 / 100
96 ms924 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; int arr[20010]; long long mem[20010]; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, m, k, i, j; scanf("%d%d%d", &n, &m, &k); for(i = 1; i <= n; i++) scanf("%d", &arr[i]); mem[0] = 0; for(i = 1; i <= n; i++) mem[i] = 1e14; for(i = 1; i <= n; i++) { int mx = arr[i]; int mn = arr[i]; for(j = i; j > i - m && j >= 1; j--) { mx = max(arr[j], mx); mn = min(arr[j], mn); long long r = k + 1LL * (i - j + 1) * (mx - mn) + mem[j - 1]; mem[i] = min(r, mem[i]); } } printf("%lld\n", mem[n]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
2016_ho_t1.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...