zoukankan      html  css  js  c++  java
  • C

    Problem Statement

    Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.

    The vacation consists of NN days. For each ii (1iN1≤i≤N), Taro will choose one of the following activities and do it on the ii-th day:

    • A: Swim in the sea. Gain aiai points of happiness.
    • B: Catch bugs in the mountains. Gain bibi points of happiness.
    • C: Do homework at home. Gain cici points of happiness.

    As Taro gets bored easily, he cannot do the same activities for two or more consecutive days.

    Find the maximum possible total points of happiness that Taro gains.

    Constraints

    • All values in input are integers.
    • 1N1051≤N≤105
    • 1ai,bi,ci1041≤ai,bi,ci≤104

    Input

    Input is given from Standard Input in the following format:

    NN
    a1a1 b1b1 c1c1
    a2a2 b2b2 c2c2
    ::
    aNaN bNbN cNcN
    

    Output

    Print the maximum possible total points of happiness that Taro gains.


    Sample Input 1 Copy

    Copy
    3
    10 40 70
    20 50 80
    30 60 90
    

    Sample Output 1 Copy

    Copy
    210
    

    If Taro does activities in the order C, B, C, he will gain 70+50+90=21070+50+90=210 points of happiness.


    Sample Input 2 Copy

    Copy
    1
    100 10 1
    

    Sample Output 2 Copy

    Copy
    100
    

    Sample Input 3 Copy

    Copy
    7
    6 7 8
    8 8 3
    2 5 2
    7 8 6
    4 6 8
    2 3 4
    7 5 1
    

    Sample Output 3 Copy

    Copy
    46
    

    Taro should do activities in the order C, A, B, A, C, B, A.

  • 相关阅读:
    单例模式(Singleton)
    建造者模式(Builder和Director)
    原型模式(Prototype)
    备忘录模式(Memento)
    观察者模式(Observer)
    工厂模式(Factory)
    状态模式(State)
    模板方法模式(Template Method)
    策略模式(Strategy)
    微信小程序------小程序初步学习
  • 原文地址:https://www.cnblogs.com/dealer/p/13130118.html
Copyright © 2011-2022 走看看