Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX( a, b ) ( ( a > b) ? a : b )
- void main(void) {
- const int n =6;
- int a[n]={5,1,2,3,99,115};
- int sum_table[2] = {a[0], a[1]}; for(int i = 2; i < n; i++){ int tmp = sum_table[1]; sum_table[1] = sum_table[0] + a[i];
- sum_table[0] = MAX(sum_table[0], tmp);
- }
- int ans = MAX(sum_table[0], sum_table[1]);
- printf("%d",ans);
- }
Add Comment
Please, Sign In to add comment