답안 #829159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829159 2023-08-18T05:39:38 Z 1075508020060209tc Kitchen (BOI19_kitchen) C++14
21 / 100
91 ms 92208 KB
#pragma GCC optimize("Ofast, no-stack-protector, unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
int n;int m;int K;
int ar[510];
int br[510];

int dp[310][90010];

signed main()
{
    cin>>n>>m>>K;
    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }
    for(int i=1;i<=m;i++){
        cin>>br[i];
    }
    int S=0;
    for(int i=1;i<=n;i++){
        if(ar[i]<K){cout<<"Impossible";return 0;}
        S+=ar[i];
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<=90000;j++){
            if(dp[i][j]==0&&i!=0){continue;}
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            int v=j+br[i+1];
            if(v>90000){continue;}
            dp[i+1][v]=max(dp[i+1][v],dp[i][j]+min(n,br[i+1]));
        }
    }
    for(int i=S;i<=90000;i++){
        if(dp[m][i]>=n*K){
            cout<<i-S<<endl;return 0;
        }
    }
    cout<<"Impossible";
}

Compilation message

kitchen.cpp:1:63: warning: bad option '-f no-stack-protector' to pragma 'optimize' [-Wpragmas]
    1 | #pragma GCC optimize("Ofast, no-stack-protector, unroll-loops")
      |                                                               ^
kitchen.cpp:1:63: warning: bad option '-f unroll-loops' to pragma 'optimize' [-Wpragmas]
kitchen.cpp:11:13: warning: bad option '-f no-stack-protector' to attribute 'optimize' [-Wattributes]
   11 | signed main()
      |             ^
kitchen.cpp:11:13: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 91 ms 92208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 14292 KB Output is correct
2 Correct 14 ms 14364 KB Output is correct
3 Correct 14 ms 14388 KB Output is correct
4 Correct 14 ms 14344 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 948 KB Output isn't correct
3 Halted 0 ms 0 KB -