답안 #394462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394462 2021-04-26T17:11:11 Z rocks03 Feast (NOI19_feast) C++14
21 / 100
127 ms 460 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 300+100;
const int MAXK = 300+100;
int N, K, a[MAXN];
ll pr[MAXN], dp[MAXN], dp2[MAXN];

void solve(){
    cin >> N >> K;
    rep(i, 1, N + 1){
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
    }
    rep(k, 1, K + 1){
        rep(i, 1, N + 1){
            dp2[i] = dp2[i - 1];
            ll mx = 0, s = 0;
            per(j, i, 1){
                s += a[j];
                if(s < 0) s = 0;
                mx = max(mx, s);
                dp2[i] = max(dp2[i], dp[j - 1] + mx);
            }
        }
        swap(dp, dp2);
    }
    cout << dp[N];
}
 
int main(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 452 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 452 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Incorrect 1 ms 332 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -