| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1290610 | SmuggingSpun | Feast (NOI19_feast) | C++20 | 24 ms | 1552 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
typedef long long ll;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
const int lim = 3e5 + 5;
const ll INF = 1e18;
int n, k, a[lim];
namespace sub1{
void solve(){
cout << accumulate(a + 1, a + n + 1, 0LL);
}
}
namespace sub2345{
void solve(){
vector<vector<ll>>dp(n + 1, vector<ll>(k + 1, -INF));
dp[0][0] = 0;
for(int i = 1; i <= n; i++){
dp[i] = dp[i - 1];
ll sum = 0;
for(int j = i; j > 0; j--){
sum += a[j];
for(int t = 1; t <= k; t++){
maximize(dp[i][t], dp[j - 1][t - 1] + sum);
}
}
}
cout << *max_element(dp[n].begin(), dp[n].end());
}
}
namespace sub67{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
if(*min_element(a + 1, a + n + 1) > -1){
sub1::solve();
}
else if(max(n, k) <= 300){
sub2345::solve();
}
else{
sub67::solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
