Submission #833227

#TimeUsernameProblemLanguageResultExecution timeMemory
833227kwongwengFeast (NOI19_feast)C++17
21 / 100
1086 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second void solve(){ int n,k; cin>>n>>k; vi a(n+1); FOR(i,1,n+1) cin>>a[i]; ll dp[n+1][k+1]; ms(dp,0,sizeof(dp)); FOR(i,1,n+1){ FOR(j,1,k+1){ dp[i][j]=max(dp[i][j],dp[i][j-1]); dp[i][j]=max(dp[i][j],dp[i-1][j]); ll sm=0; FOR(l,1,i+1){ sm+=a[i-l+1]; dp[i][j]=max(dp[i][j],sm+dp[i-l][j-1]); } //cout<<dp[i][j]<<" "; } //cout<<"\n"; } cout<<dp[n][k]<<"\n"; } int main(){ //MOD=MOD1; ios::sync_with_stdio(false); if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int TC = 1; //cin >> TC; FOR(i, 1, TC+1){ //cout << "Case #" << i << ": "; solve(); } return 0; }

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:40:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
feast.cpp:41:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |      freopen("output.txt", "w", stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...