제출 #791438

#제출 시각아이디문제언어결과실행 시간메모리
791438cheat_when_I_was_youngFeast (NOI19_feast)C++17
21 / 100
1051 ms15632 KiB
// #cheat_when_we_are_young // #cheatkhitacontre #khionhatoicheat // #thaycuckythatvong #include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define int long long using namespace std; const int NM = 2005; int n, k, a[NM], dp[NM][NM]; signed main() { IOS; cin >> n >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; a[i] += a[i-1]; } for (int i = 1; i <= n; ++i) for (int j = 1; j <= k; ++j) { dp[i][j] = max(dp[i][j], dp[i-1][j]); for (int p = 0; p < i; ++p) dp[i][j] = max(dp[i][j], dp[p][j-1] + a[i] - a[p]); } cout << dp[n][k]; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...