Submission #833139

#TimeUsernameProblemLanguageResultExecution timeMemory
833139isaachewFeast (NOI19_feast)C++17
59 / 100
1090 ms11000 KiB
#include <bits/stdc++.h> /* */ int main(){ int n,k; std::cin>>n>>k; std::vector<int> nums; for(int i=0;i<n;i++){ int x; std::cin>>x; nums.push_back(x); } std::vector<long long> seg(n+1);//segment active std::vector<long long> noseg(n+1);//no segment active for(int i=0;i<k;i++){ std::vector<long long> seg2(n+1); std::vector<long long> noseg2(n+1); for(int j=1;j<n+1;j++){ seg2[j]=std::max(noseg[j],seg2[j-1]+nums[j-1]); noseg2[j]=std::max(seg2[j],noseg2[j-1]); } seg=seg2,noseg=noseg2; } std::cout<<noseg[n]<<'\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...