Submission #35748

#TimeUsernameProblemLanguageResultExecution timeMemory
35748amidethuong2Split the sequence (APIO14_sequence)C++98
0 / 100
0 ms2372 KiB
#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 (stderr)

sequence.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#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...