Submission #216925

# Submission time Handle Problem Language Result Execution time Memory
216925 2020-03-28T13:01:55 Z someone_aa K blocks (IZhO14_blocks) C++17
0 / 100
5 ms 640 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 110;
int n, k;
int dp[maxn][maxn];
int a[maxn];

int main() {
	cin>>n>>k;
	int prefmax = 0;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		prefmax = max(prefmax, a[i]);
		dp[i][1] = prefmax;
	}

	for(int d=2;d<=k;d++) {
		bool check = false;
		for(int i=d;i<=n;i++) {
			dp[i][d] = INT_MAX;
			int prefmax = 0;
			for(int p=i;p>=d;p--) {
				prefmax = max(prefmax, a[p]);
				dp[i][d] = min(dp[i][d], dp[p-1][d-1] + prefmax);
			}

			if(dp[i][d] < dp[i-1][d]) check = true;
		}

		if(check) cout<<(1/0);
	}

	cout<<dp[n][k]<<"\n";
}

Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:33:21: warning: division by zero [-Wdiv-by-zero]
   if(check) cout<<(1/0);
                    ~^~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Runtime error 5 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Runtime error 5 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -