# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
833231 | 2023-08-22T03:27:10 Z | josanneo22 | Feast (NOI19_feast) | C++17 | 236 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define mp make_pair #define pb push_back #define pii pair<int,int> #define fi first #define se second #define all(x) x.begin(), x.end() #define ar array const int inf=1e15; void solve(){ int n,k; cin>>n>>k; vector<int> a(n+1); for(int i=1;i<=n;i++) cin>>a[i]; vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(n+1,vector<int>(2,-inf))); dp[0][0][0]=0; dp[0][0][1]=0; int ans=0; for(int i=1;i<=n;i++){ dp[i][0][0]=0; for(int j=1;j<=n;j++){ dp[i][j][0]=max(dp[i-1][j][0],dp[i-1][j][1]); dp[i][j][1]=max(dp[i-1][j][1],dp[i-1][j-1][0])+a[i]; if(j<=k) ans=max(ans,max(dp[i][j][0],dp[i][j][1])); } } cout<<ans<<'\n'; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); clock_t tStart = clock(); int local=0,multi=0,debug=1,tt=1; if(local){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); } if(multi) cin>>tt; for(int i=1;i<=tt;i++){ if(debug && multi && local) cout<<"样例 "<<i<<'\n'; solve(); } fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 203 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 183 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 188 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 5 ms | 5076 KB | Output is correct |
12 | Correct | 4 ms | 3924 KB | Output is correct |
13 | Correct | 3 ms | 4052 KB | Output is correct |
14 | Correct | 4 ms | 4532 KB | Output is correct |
15 | Correct | 4 ms | 4308 KB | Output is correct |
16 | Correct | 3 ms | 3924 KB | Output is correct |
17 | Correct | 4 ms | 4564 KB | Output is correct |
18 | Correct | 4 ms | 4436 KB | Output is correct |
19 | Correct | 4 ms | 4308 KB | Output is correct |
20 | Correct | 5 ms | 5076 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 5 ms | 5076 KB | Output is correct |
12 | Correct | 4 ms | 3924 KB | Output is correct |
13 | Correct | 3 ms | 4052 KB | Output is correct |
14 | Correct | 4 ms | 4532 KB | Output is correct |
15 | Correct | 4 ms | 4308 KB | Output is correct |
16 | Correct | 3 ms | 3924 KB | Output is correct |
17 | Correct | 4 ms | 4564 KB | Output is correct |
18 | Correct | 4 ms | 4436 KB | Output is correct |
19 | Correct | 4 ms | 4308 KB | Output is correct |
20 | Correct | 5 ms | 5076 KB | Output is correct |
21 | Correct | 192 ms | 207308 KB | Output is correct |
22 | Correct | 189 ms | 204968 KB | Output is correct |
23 | Correct | 190 ms | 208332 KB | Output is correct |
24 | Correct | 188 ms | 207588 KB | Output is correct |
25 | Correct | 236 ms | 219912 KB | Output is correct |
26 | Correct | 200 ms | 218060 KB | Output is correct |
27 | Correct | 207 ms | 218596 KB | Output is correct |
28 | Correct | 196 ms | 217520 KB | Output is correct |
29 | Correct | 202 ms | 213608 KB | Output is correct |
30 | Correct | 186 ms | 206216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 203 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |