Submission #394476

#TimeUsernameProblemLanguageResultExecution timeMemory
394476rocks03Feast (NOI19_feast)C++14
59 / 100
1089 ms6880 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 3e5+100; int N, K, a[MAXN]; ll dp[MAXN]; void solve(){ cin >> N >> K; rep(i, 1, N + 1){ cin >> a[i]; } rep(k, 1, K + 1){ ll s = 0, mx = 0; rep(i, 1, N + 1){ s += a[i]; s = max(s, dp[i]); mx = max(mx, s); dp[i] = mx; } } cout << dp[N]; } int main(){ ios_base::sync_with_stdio(false), cin.tie(nullptr); solve(); return 0; }
#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...