제출 #819249

#제출 시각아이디문제언어결과실행 시간메모리
819249SteGGFinancial Report (JOI21_financial)C++17
0 / 100
4046 ms5120 KiB
#include <bits/stdc++.h>
#define int long long

using namespace std;

void open(){
	if(fopen("input.inp", "r")){
		freopen("input.inp", "r", stdin);
		//freopen("output.out", "w", stdout);
	}
}

const int maxn = 3e5 + 5;
const int inf = 1e9 + 7;

int n, d;
int arr[maxn];
int dp[maxn];

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	open();
	cin >> n >> d;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}

	dp[1] = 1;
	int result = 1;
	for(int i = 2; i <= n; i++){
		dp[i] = 1;
		for(int j = i - d + 1; j < i; j++){
			if(arr[j] < arr[i]){
				dp[i] = max(dp[i], dp[j] + 1);
			}
		}

		for(int j = i - d; j > 0; j--){
			if(arr[j] >= arr[i]) break;
			dp[i] = max(dp[i], dp[j] + 1);
		}

		int temp = dp[i];
		for(int j = 1; j < i; j++){
			if(arr[j] > arr[i]){
				temp = max(temp, dp[j]);
			}
		}

		result = max(result, temp);

		// cout << temp << " " << dp[i] << " " << i << endl;
	}

	assert(n != 20 || result != 5);

	cout << result << endl;

	return 0;
}

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

Main.cpp: In function 'void open()':
Main.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   freopen("input.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...