http://www.geeksforgeeks.org/maximum-sum-such-that-no-two-elements-are-adjacent/

 #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <fstream>
#include <map>
using namespace std; int maxsum(int arr[], int n) {
int insum = arr[];
int exsum = ;
for (int i = ; i < n; i++) {
int tmp = max(insum, exsum);
insum = exsum + arr[i];
exsum = tmp;
}
return max(insum, exsum);
} int main() {
int arr[] = {, , , , , };
cout << maxsum(arr, ) << endl;
return ;
}
05-28 21:46