제출 #224685

#제출 시각아이디문제언어결과실행 시간메모리
224685NightlightFeast (NOI19_feast)C++14
0 / 100
16 ms4352 KiB
#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); }

컴파일 시 표준 에러 (stderr) 메시지

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]);
     ~~~~~^~~~~~~~~~~~~~~~~
#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...