Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("cladire2.in");
- ofstream fout("cladire2.out");
- int n,a[101][101],b[101][101];
- struct camera{int l,c;}v[101];
- int main()
- {
- fin>>n;
- for(int i=1;i<=n;i++)
- for(int j=1;j<=m;j++)
- fin>>a[i][j];
- b[1][1]=a[1][1];
- v[1].l=1;
- v[2].c=1;
- for(int j=2;j<=n;j++)
- b[1][j]=b[1][j-1]+a[1][j];
- for(int i=2;i<=n;i++)
- b[i][1]=b[i-1][1]+a[i][1];
- for(int i=2;i<=n;i++)
- for(int j=2;j<=m;j++)
- b[i][j]=max(b[i-1][j],b[i][j-1])+a[i][j];
- fout<<b[n][m];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement