제출 #936155

#제출 시각아이디문제언어결과실행 시간메모리
936155shoryu386The short shank; Redemption (BOI21_prison)C++17
0 / 100
1 ms2396 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int n, d, t;
#define MAX 2000007

int arr[MAX], dp[MAX];
int cost(int l, int r){
	int ans = 0;

	if (arr[l] <= t) ans++;
	
	int carry = arr[l] + 1;
	for (int x = l+1; x <= r; x++){
		int val = min(arr[x], carry);
		if (val <= t) ans++;
		
		carry = min(carry, arr[x]);
		carry += 1;
	}
	
	return ans;
}

main(){
	cin >> n >> d >> t;
	for (int x = 0; x < n; x++) cin >> arr[x];
	
	for (int x = 0; x < n; x++){
		dp[x] = cost(0, x);
	
		for (int y = 0; y < x; y++){
			dp[x] = min(dp[x], dp[y] + cost(y+1, x));
		}
	}
	cout << dp[n-1];
}

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

prison.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...