답안 #646181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646181 2022-09-29T03:46:43 Z kith14 Feast (NOI19_feast) C++17
21 / 100
1000 ms 31956 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define db double
#define pairll pair<ll,ll>
#define lpairll pair<ll,pairll>

#define repp(i,a,b) for (ll i = a; i <= b; i++)
#define repz(i,a,b) for (ll i = a; i < b; i++)
#define repm(i,a,b) for (ll i = a; i >= b; i--)
#define fr first
#define sc second
#define x first
#define y second
#define mp make_pair
#define pb push_back

const ll N = 2e3+5, MOD = 1e9+7;
ll tc = 1, n, m, ar[N], br[N], dp[N][N];
string s, s1, s2, ye = "YA", no = "TIDAK";

void input(){
  cin >> n >> m;
  repp(i,1,n) cin >> ar[i];
}

ll rec(ll idx, ll rem){
  if (rem == 0) return 0;
  if (idx > n) return 0;
  if (dp[idx][rem] != -1) return dp[idx][rem];

  ll ret = rec(idx+1,rem), cur = 0 , maxi = 0;
  repp(i,idx,n){
    cur += ar[i];
    maxi = max(maxi,cur);
    if (cur < 0) cur = 0;
    ret = max(ret,maxi+rec(i+1,rem-1));
  }
  //cout << idx << " " << rem << " " << ret << endl;
  return dp[idx][rem] = ret;
}

void solve(){
  memset(dp,-1,sizeof(dp));
  cout << rec(1,m) << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  //cin >> tc;
  while(tc--){
    input();
    solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 31832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 31816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31800 KB Output is correct
2 Correct 14 ms 31688 KB Output is correct
3 Correct 13 ms 31772 KB Output is correct
4 Correct 13 ms 31700 KB Output is correct
5 Correct 13 ms 31684 KB Output is correct
6 Correct 12 ms 31692 KB Output is correct
7 Correct 13 ms 31820 KB Output is correct
8 Correct 12 ms 31700 KB Output is correct
9 Correct 11 ms 31688 KB Output is correct
10 Correct 12 ms 31684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31800 KB Output is correct
2 Correct 14 ms 31688 KB Output is correct
3 Correct 13 ms 31772 KB Output is correct
4 Correct 13 ms 31700 KB Output is correct
5 Correct 13 ms 31684 KB Output is correct
6 Correct 12 ms 31692 KB Output is correct
7 Correct 13 ms 31820 KB Output is correct
8 Correct 12 ms 31700 KB Output is correct
9 Correct 11 ms 31688 KB Output is correct
10 Correct 12 ms 31684 KB Output is correct
11 Correct 19 ms 31828 KB Output is correct
12 Correct 15 ms 31828 KB Output is correct
13 Correct 13 ms 31832 KB Output is correct
14 Correct 15 ms 31824 KB Output is correct
15 Correct 16 ms 31728 KB Output is correct
16 Correct 16 ms 31800 KB Output is correct
17 Correct 15 ms 31828 KB Output is correct
18 Correct 12 ms 31828 KB Output is correct
19 Correct 13 ms 31780 KB Output is correct
20 Correct 16 ms 31772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31800 KB Output is correct
2 Correct 14 ms 31688 KB Output is correct
3 Correct 13 ms 31772 KB Output is correct
4 Correct 13 ms 31700 KB Output is correct
5 Correct 13 ms 31684 KB Output is correct
6 Correct 12 ms 31692 KB Output is correct
7 Correct 13 ms 31820 KB Output is correct
8 Correct 12 ms 31700 KB Output is correct
9 Correct 11 ms 31688 KB Output is correct
10 Correct 12 ms 31684 KB Output is correct
11 Correct 19 ms 31828 KB Output is correct
12 Correct 15 ms 31828 KB Output is correct
13 Correct 13 ms 31832 KB Output is correct
14 Correct 15 ms 31824 KB Output is correct
15 Correct 16 ms 31728 KB Output is correct
16 Correct 16 ms 31800 KB Output is correct
17 Correct 15 ms 31828 KB Output is correct
18 Correct 12 ms 31828 KB Output is correct
19 Correct 13 ms 31780 KB Output is correct
20 Correct 16 ms 31772 KB Output is correct
21 Execution timed out 1093 ms 31956 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -