• [H] Orianna

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Orianna is the lady of clockwork that fights in League of Legends. She fights with her ball.

    Today, Corin, Orianna's father builds a new ball for her.

    That ball contains 5 levels attack mode named M1, M2, M3, M4 and M5. But there's a strange rule in using the mode - once she attack in one mode and the previous attack is in a lower mode, she can only use a lower mode than this time in the next attack. Other wise, when she attack in one mode and the previous one is in a higher mode, she can only use a higher mode than this time in the next attack.

    For example, her previous attack is using M3 and her current mode is M4, then she can only use M1, M2, M3 in the next attack.

    Since all kinds of reasons (physical condition, mentation, etc.), the damage of each attack in each mode of each time in one competition is different.

    Give you the damage of each attack in each mode of each time in one competition, you should help Orianna to design an attack planning that makes the damage maximum.

  • 输入
  • This problem contains several cases. The first line of each case is an integer N, indicates the number of times that Orianna should attack. (4 ≤ N ≤ 100000).
    Next follow 5 lines, indicate M1, M2, M3, M4 and M5. Each line contains N integers that means the ith attack damage if using this mode. Each single damage will not exceeds 1000.
  • 输出
  • For each case, you should output the maximum damage.
  • 样例输入
  • 5
    3 2 1 4 1
    2 3 3 1 2
    4 1 2 3 1
    2 4 2 1 3
    2 1 2 3 4
    
  • 样例输出
  • 17
  • 提示
  • 来源
  • XadillaX
  • 操作

显示春菜