Submission #243457

# Submission time Handle Problem Language Result Execution time Memory
243457 2020-07-01T08:18:22 Z N1NT3NDO Pohlepko (COCI16_pohlepko) C++14
40 / 80
67 ms 65540 KB
#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(short i=0;i<n;i++)
    for(short j=0;j<m;j++) cin >> c[i][j];
  dp[0][0]=c[0][0];
  for(short i=0;i<n;i++)
    for(short 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 time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 15 ms 8576 KB Output is correct
6 Runtime error 62 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 64 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 42 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Correct 6 ms 1408 KB Output is correct
10 Correct 50 ms 33536 KB Output is correct
11 Runtime error 56 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 67 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 61 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 43 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Correct 11 ms 4736 KB Output is correct
16 Runtime error 65 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)