Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n;
- cin>>n;
- int a, b, c;
- cin>>a>>b>>c;
- for(int i=1;i<n;i++){
- int k1, k2, k3;
- cin>>k1>>k2>>k3;
- int a1, b1, c1;
- a1=max(a+k1, max(b+k1, c+k1));
- c1=max(a+k3, max(b+k3, c+k3));
- b1=max(a+k2, c+k2);
- a=a1;
- b=b1;
- c=c1;
- }
- cout<<max(a, max(b,c));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement