제출 #791417

#제출 시각아이디문제언어결과실행 시간메모리
791417vjudge1Feast (NOI19_feast)C++17
0 / 100
1065 ms7580 KiB
// #cheat_when_we_are_young // #cheatkhitacontre #khionhatoicheat // #thaycuckythatvong #include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define int long long #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using namespace std; signed main() { IOS; int n, m, k; cin >> n >> k; int a[n+1], p[n+1], dp[n+1]; for (int i = 1; i <= n; ++i) cin >> a[i]; p[0] = 1; for (int i = 1; i <= n; ++i) p[i] = p[i-1]+a[i]; memset(dp,0,sizeof(dp)); for (int i = k; i <= n; ++i) { dp[i] = max(dp[i],dp[i-1]); m = min(i,2*k-1); for (int j = k; j <= m; ++j) dp[i] = max(dp[i], dp[i-j]+p[i]-p[i-j]); } cout << dp[n]; }
#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...