Submission #1050983

# Submission time Handle Problem Language Result Execution time Memory
1050983 2024-08-09T17:41:22 Z mychecksedad Candies (JOI18_candies) C++17
8 / 100
5 ms 33528 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
const int N = 2000+100, M = 1e5+10, K = 52, MX = 30;


int n;
ll a[N], dp[N][N];
void solve(){
  cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> a[i]; 
  }
  for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) dp[i][j] = 0;
  // for(int i = 0; i <= n; ++i) dp[0][i] = -1e15;
  dp[1][1] = a[1];
  for(int i = 2; i <= n; ++i){
    for(int j = 1; j <= (i+1)/2; ++j){
      dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + a[i]);
      // cout << dp[i][j] << ' ';
    }
    // en;
  }
  for(int j = 1; j <= (n+1)/2; ++j){
    ll mx = 0;
    cout << dp[n][j] << '\n';
  }
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  while(tt--){
    solve();
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 

Compilation message

candies.cpp: In function 'void solve()':
candies.cpp:33:8: warning: unused variable 'mx' [-Wunused-variable]
   33 |     ll mx = 0;
      |        ^~
candies.cpp: In function 'int main()':
candies.cpp:41:15: warning: unused variable 'aa' [-Wunused-variable]
   41 |   int tt = 1, aa;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 33372 KB Output is correct
2 Correct 4 ms 33372 KB Output is correct
3 Correct 4 ms 33372 KB Output is correct
4 Correct 4 ms 33520 KB Output is correct
5 Correct 4 ms 33372 KB Output is correct
6 Correct 4 ms 33372 KB Output is correct
7 Correct 4 ms 33372 KB Output is correct
8 Correct 4 ms 33504 KB Output is correct
9 Correct 4 ms 33484 KB Output is correct
10 Correct 4 ms 33372 KB Output is correct
11 Correct 4 ms 33372 KB Output is correct
12 Correct 4 ms 33372 KB Output is correct
13 Correct 5 ms 33372 KB Output is correct
14 Correct 4 ms 33372 KB Output is correct
15 Correct 5 ms 33528 KB Output is correct
16 Correct 4 ms 33504 KB Output is correct
17 Correct 4 ms 33372 KB Output is correct
18 Correct 5 ms 33488 KB Output is correct
19 Correct 4 ms 33372 KB Output is correct
20 Correct 4 ms 33372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 33372 KB Output is correct
2 Correct 4 ms 33372 KB Output is correct
3 Correct 4 ms 33372 KB Output is correct
4 Correct 4 ms 33520 KB Output is correct
5 Correct 4 ms 33372 KB Output is correct
6 Correct 4 ms 33372 KB Output is correct
7 Correct 4 ms 33372 KB Output is correct
8 Correct 4 ms 33504 KB Output is correct
9 Correct 4 ms 33484 KB Output is correct
10 Correct 4 ms 33372 KB Output is correct
11 Correct 4 ms 33372 KB Output is correct
12 Correct 4 ms 33372 KB Output is correct
13 Correct 5 ms 33372 KB Output is correct
14 Correct 4 ms 33372 KB Output is correct
15 Correct 5 ms 33528 KB Output is correct
16 Correct 4 ms 33504 KB Output is correct
17 Correct 4 ms 33372 KB Output is correct
18 Correct 5 ms 33488 KB Output is correct
19 Correct 4 ms 33372 KB Output is correct
20 Correct 4 ms 33372 KB Output is correct
21 Runtime error 1 ms 604 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -