Submission #101306

#TimeUsernameProblemLanguageResultExecution timeMemory
101306b2563125Candies (JOI18_candies)C++14
8 / 100
715 ms525312 KiB
#include<iostream> #include<vector> #include<string> #include<stack> #include<queue> #include<utility> #include<algorithm> using namespace std; #define int long long #define vel vector<int> #define vvel vector<vel> #define vvvel vector<vvel> #define veb vector<bool> void mmax(int &a, int b) { a = max(a, b); } vel ret_normal(int st, int to, vel &a) { int siz = to - st; int ko = (siz + 3) / 2; vvel dp(siz+1, vel(ko, -1)); dp[0][0] = 0; dp[1][0] = 0; dp[1][1] = a[st]; for (int i = 2; i <= siz; i++) { dp[i] = dp[i - 1]; for (int j = 1; j < ko; j++) { if (dp[i - 2][j - 1] != -1) { mmax(dp[i][j], dp[i - 2][j - 1] + a[st + i - 1]); } } } return dp[siz]; } signed main() { int n; cin >> n; vel a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vel ans((n + 3) / 2); ans=ret_normal(0, n, a); for (int i = 1; i < ans.size(); i++) { cout << ans[i] << endl; } return 0; }

Compilation message (stderr)

candies.cpp: In function 'int main()':
candies.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < ans.size(); i++) { cout << ans[i] << endl; }
                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...