답안 #130389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130389 2019-07-15T06:00:22 Z aer0park 요리 강좌 (KOI17_cook) C++14
0 / 100
3 ms 1272 KB
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll n,m,s,e,t,mnc[3005],anw=1e15;
int c[3005][6005],pc[3005][6005],x[3005]; // c:i번쨰 학원에서  j번강좌를 들을 경우 비용  pc:i번쨰 학원에서 j번강좌까지를 들을 경우 비용 
ll dp[3005][6005],ck[3005][6005];  // i번쨰 학원에서 j번 강좌까지를 끝마쳤을때 최소비용 즉 무조건 학원바꿈  

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>s>>e>>t;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>c[i][j],pc[i][j]=pc[i][j-1]+c[i][j];
     for(int i=1;i<=n;i++)
        for(int j=m+1;j<=m+s;j++)
            pc[i][j]=pc[i][j-1];    
    for(int i=1;i<=n;i++)
        cin>>x[i];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m+s;j++)
            dp[i][j]=1e15; 
    for(int i=1;i<=n;i++)
        dp[i][0]=-t;
    for(int i=0;i<=m;i++)
    {
        ll nw=i+s;
        for(int j=1;j<=n;j++)
            if(ck[j][nw-1])
                ck[j][nw]=ck[j][nw-1]-1,dp[j][nw]=min(dp[j][nw-1]+c[j][nw],dp[j][nw]);
        vector<pi> ar;
        for(int j=1;j<=n;j++)
            ar.push_back({dp[j][i]+t,j});
        sort(ar.begin(),ar.end());
        for(int j=1;j<=n;j++)
        {
            ll k=0; 
            while(ar[k].se==x[j]||ar[k].se==j)
                k++;
            mnc[j]=ar[k].fi;
        }
        for(int j=1;j<=n;j++)
            if(dp[j][nw]>=mnc[j]+pc[j][nw]-pc[j][i])
                dp[j][nw]=mnc[j]+pc[j][nw]-pc[j][i],ck[j][nw]=e-s;
    }
    for(int i=1;i<=n;i++)
        for(int j=m;j<=m+s;j++)
            anw=min(anw,dp[i][j]);
    cout<<anw;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 3 ms 1272 KB Output is correct
4 Correct 3 ms 888 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Incorrect 3 ms 1272 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 3 ms 1272 KB Output is correct
4 Correct 3 ms 888 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Incorrect 3 ms 1272 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 3 ms 1272 KB Output is correct
4 Correct 3 ms 888 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Incorrect 3 ms 1272 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 3 ms 1272 KB Output is correct
4 Correct 3 ms 888 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Incorrect 3 ms 1272 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 3 ms 1272 KB Output is correct
4 Correct 3 ms 888 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Incorrect 3 ms 1272 KB Output isn't correct
7 Halted 0 ms 0 KB -