제출 #864350

#제출 시각아이디문제언어결과실행 시간메모리
864350ElenaBMPohlepko (COCI16_pohlepko)C++17
40 / 80
77 ms65536 KiB
#include <bits/stdc++.h> using namespace std; int main() { /* hacer una dp bidimensional en la que se pondra la solucion lexicograficamente menor en cada casilla*/ int x, y; cin>> x >> y; vector<vector<char>> tab(x, vector<char>(y)); vector<vector<string>> dp (x, vector<string>(y)); for (int i = 0; i < x; ++i){ for (int j = 0; j < y; ++j){ cin>> tab[i][j]; } } dp[0][0] = tab[0][0]; for (int i = 1; i < x; ++i)dp[i][0] = dp[i-1][0] + tab[i][0]; for (int j = 1; j < y; ++j)dp[0][j] = dp[0][j-1] + tab[0][j]; for (int i = 1; i < x; ++i){ for (int j = 1; j <y ; ++j){ dp[i][j] = min(dp[i-1][j], dp[i][j-1])+ tab[i][j]; } } cout<< dp[x-1][y-1] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...