답안 #224685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224685 2020-04-18T15:18:43 Z Nightlight Feast (NOI19_feast) C++14
0 / 100
16 ms 4352 KB
#include <bits/stdc++.h>
using namespace std;

int N, K;
long long pre[3005];
long long dp[3005][3005];
long long ans = 0;
//udah ambil berapa, ada dimana

int main() {
//  freopen("inp", "r", stdin);
  scanf("%d %d", &N, &K);
  for(int i = 1; i <= N; i++) {
    scanf("%lld", &pre[i]);
    cout << pre[i] << " ";
    pre[i] += pre[i - 1];
  }
  puts("");
  //i = sudah ambil berapa
  //j = ada dimana
  for(int i = 1; i <= K; i++) {
    long long best = dp[i - 1][i - 1] - pre[i - 1];
    long long bestdp = dp[i - 1][i - 1];
    for(int j = i; j <= N; j++) {
      dp[i][j] = pre[j] + best;
      bestdp = max(dp[i - 1][j], bestdp);
      best = max(best, bestdp - pre[j]);
      ans = max(ans, dp[i][j]);
    }
  }
  printf("%lld\n", ans);
}

Compilation message

feast.cpp: In function 'int main()':
feast.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &N, &K);
   ~~~~~^~~~~~~~~~~~~~~~~
feast.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &pre[i]);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 4352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 4352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -