답안 #86248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86248 2018-11-25T14:50:53 Z tjdgus4384 요리 강좌 (KOI17_cook) C++14
0 / 100
46 ms 36120 KB
#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;
int c[3001][3001];
int cant[3001], csum[3001][3001];
int d[3001][3001], ans = 1000000000, n, m, s, e, t;

int recur(int x, int y)
{
    if(y == 0) return 0;
    if(y < s) return 1000000000;
    if(d[x][y] != -1) return d[x][y];
    d[x][y] = 1000000000;
    for(int i = s;i <= e;i++)
    {
        if(y < i) break;
        int ret = csum[x][y] - csum[x][y - i];
        int a = 1000000000;
        for(int j = 1;j <= n;j++)
        {
            if(j == x || j == cant[x]) continue;
            a = min(a, recur(j, y - i));
        }
        d[x][y] = min(d[x][y], ret + a);
    }
    d[x][y] += t;
    return d[x][y];
}

int main()
{
    scanf("%d %d %d %d %d", &n, &m, &s, &e, &t);
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            scanf("%d", &c[i][j]);
            csum[i][j] = csum[i][j - 1] + c[i][j];
        }
    }
    for(int i = 1;i <= n;i++) scanf("%d", &cant[i]);
    memset(d, -1, sizeof(d));
    for(int i = 1;i <= n;i++)
    {
        ans = min(ans, recur(i, m));
    }
    printf("%d", ans - t);
    return 0;
}

Compilation message

cook.cpp: In function 'int main()':
cook.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d %d", &n, &m, &s, &e, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cook.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &c[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
cook.cpp:42:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1;i <= n;i++) scanf("%d", &cant[i]);
                               ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 35960 KB Output is correct
2 Incorrect 32 ms 36120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 35960 KB Output is correct
2 Incorrect 32 ms 36120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 35960 KB Output is correct
2 Incorrect 32 ms 36120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 35960 KB Output is correct
2 Incorrect 32 ms 36120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 35960 KB Output is correct
2 Incorrect 32 ms 36120 KB Output isn't correct
3 Halted 0 ms 0 KB -