Submission #1276646

#TimeUsernameProblemLanguageResultExecution timeMemory
1276646SmuggingSpunSličice (COCI19_slicice)C++20
90 / 90
36 ms584 KiB
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
template<class T>void maximize(T& a, T b){
	if(a < b){
		a = b;
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	int n, m, k;
	cin >> n >> m >> k;
	vector<int>p(n), b(m + 1);
	for(int& x : p){
		cin >> x;
	}
	for(int& x : b){
		cin >> x;
	}
	vector<int>dp(k + 1, 0);
	for(int& x : p){
		for(int i = k; i > 0; i--){
			for(int j = min(i, m - x); j > 0; j--){
				maximize(dp[i], dp[i - j] + b[x + j] - b[x]);
			}
		}
	}
	int ans = dp[k];
	for(int& x : p){
		ans += b[x];
	}
	cout << ans;
}

Compilation message (stderr)

slicice.cpp: In function 'int main()':
slicice.cpp:12:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...