Codeforces Round #241 (Div. 2), problem: (B) Art Union solution: http://ideone.com/DSaHao
#include <iostream> #include <cstdio> using namespace std; int main() { int n, m, a[6]={0}, t; scanf("%d%d", &m, &n); while(m--) { for(int i=0; i<n; i++) { scanf("%d", &t); if(i==0) a[i]+=t; else { if(a[i-1]>a[i]) a[i]=a[i-1]+t; else a[i]+=t; } if(i==n-1) printf("%d ", a[i]); } } return 0; }
No comments:
Post a Comment