paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> #include <algorithm> using std::max; int main(void) { int dp[2][3],a[3],i,N; i=0; dp[0][0]=0; dp[0][1]=0; dp[0][2]=0; scanf("%d",&N); while(N--) { scanf("%d%d%d",a,a+1,a+2); dp[1-i][0]=a[0]+max(dp[i][1],dp[i][2]); dp[1-i][1]=a[1]+max(dp[i][0],dp[i][2]); dp[1-i][2]=a[2]+max(dp[i][1],dp[i][0]); i=1-i; } printf("%d\n",max(max(dp[i][0],dp[i][1]),dp[i][2])); return 0; }
comment: