제출 #243452

#제출 시각아이디문제언어결과실행 시간메모리
243452N1NT3NDOPohlepko (COCI16_pohlepko)C++14
40 / 80
71 ms65540 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back using namespace std; int n,m; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; char c[n][m]; string dp[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> c[i][j]; dp[0][0]=c[0][0]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) if (i-1>=0 && j-1>=0) dp[i][j]=min(dp[i-1][j],dp[i][j-1])+c[i][j]; else if (i-1>=0 && j-1<0) dp[i][j]=dp[i-1][j]+c[i][j]; else if (i-1<0 && j-1>=0) dp[i][j]=dp[i][j-1]+c[i][j]; cout << dp[n-1][m-1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...