답안 #35748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
35748 2017-11-29T09:07:43 Z amidethuong2 수열 (APIO14_sequence) C++
0 / 100
0 ms 2372 KB
#include <bits/stdc++.h>
using namespace std;
int cd,k,m[301],kq[301][301],t[301];
void inp()
{
	cin >> cd >> k;
	t[0] = 0;
	for (int i = 1 ; i <= cd ; i++)
	{
		cin >> m[i];
		t[i] = t[i-1] + m[i];
	}
}
void cease()
{
	int result = -1;
	for (int e = 1 ; e <= k ; e++)
	{
		for (int i = 1 ; i <= cd-1 ; i++)
		{
			kq[i][e] = -999999999;
			if (e == 1)
			{
				kq[i][e] = t[i] * (t[cd] - t[i]);
			}
			else
			{
				int Max = -1;
				for (int vl = 1 ; vl < i ; vl++)
				{
					Max = max(Max,kq[vl][e-1] + (t[i]-t[vl])*(t[cd] - t[i]) );
				}
				kq[i][e] = Max;
			}
			if (e == k) result = max(result,kq[i][e]); 
		}
	}
	cout << result;
}
main()
{
	inp();
	cease();
}

Compilation message

sequence.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -