제출 #173239

#제출 시각아이디문제언어결과실행 시간메모리
173239songc오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
51 ms1016 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, M;
LL K;
LL D[20202], A[20202];

int main(){
	scanf("%d %d %lld", &N, &M, &K);
	for (int i=1; i<=N; i++){
		scanf("%lld", &A[i]);
		D[i] = 1234567890123456ll;
		LL Max=A[i], Min=A[i];
		for (int j=1; j<=M && i-j>=0; j++){
			Max = max(Max, A[i-j+1]);
			Min = min(Min, A[i-j+1]);
			D[i] = min(D[i], D[i-j]+K+j*(Max-Min));
		}
	}
	printf("%lld\n", D[N]);
	return 0;
}

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

2016_ho_t1.cpp: In function 'int main()':
2016_ho_t1.cpp:11: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:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &A[i]);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...