Submission #1046677

# Submission time Handle Problem Language Result Execution time Memory
1046677 2024-08-06T20:10:20 Z _rain_ Holding (COCI20_holding) C++14
0 / 110
2 ms 348 KB
#include<bits/stdc++.h>
using i64 = long long;
using namespace std;

const int maxn = 100;
const int maxk = 10000;
int n,L,R,k;
i64 a[maxn+2] , f1[maxn+2][maxk+2] , dp1[maxn+2][maxn+2][maxk+2];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	#define name "main"
	freopen(name".inp","r",stdin);
	freopen(name".out","w+",stdout);

	cin >> n >> L >> R >> k;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	i64 total = 0;
	for (int i = L; i <= R; ++i) total += a[i];
	//... BUILD FOR THE LEFT
		i64 mx = 0;
		for (int i = 1; i < L; ++i)
		{
			for (int j = L; j <= R; ++j) 
			{
				for (int used = 0; used <= k; ++used)
				{
					if (used - abs(i - j) >= 0)
					{
						dp1[i][j][used] = min(dp1[i][j][used] , dp1[i - 1][j - 1][used - abs(i - j)] + a[i] - a[j]);
					}
					f1[j][used] = max(f1[j - 1][used] , dp1[i][j][used]);
				}
			}
		}
	cout << total + f1[R][k];
}

Compilation message

holding.cpp: In function 'int main()':
holding.cpp:23:7: warning: unused variable 'mx' [-Wunused-variable]
   23 |   i64 mx = 0;
      |       ^~
holding.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  freopen(name".inp","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
holding.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen(name".out","w+",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -