답안 #863843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863843 2023-10-21T08:59:20 Z edogawa_something Kitchen (BOI19_kitchen) C++17
0 / 100
273 ms 1104 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
const ll M=90000+10;
const ll inf=1e18+10;
ll n,m,k,sum,b[M];
bitset<2000>dp[2][2000];
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        if(x<k){
            cout<<"impossible\n";
            return 0;
        }
        sum+=x;
    }
    ll sb=0,sb1=0;
    for(int i=0;i<m;i++)
    cin>>b[i],sb+=b[i],sb1+=min(n,b[i]);
    sb++;
    sb1++;
    dp[0][0][0]=1;
    for(int i=0;i<m;i++){
        for(int j=0;j<sb;j++){
            for(int ii=0;ii<sb1;ii++){
            if(dp[0][j][ii]==1){
            dp[1][j+b[i]][ii+min(b[i],n)]=1;
            }
            }
        }
        for(int j=0;j<sb;j++){
            for(int ii=0;ii<sb1;ii++){
                if(dp[1][j][ii]==1)
                dp[0][j][ii]=1,dp[1][j][ii]=0;
            }
        }
    }
    for(ll i=sum;i<sb;i++){
        for(int j=n*k;j<sb1;j++){
            if(dp[0][i][j]){
                cout<<i-sum;
                return 0;
            }
        }
    }
    cout<<"impossible\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 273 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 1104 KB Output is correct
2 Correct 43 ms 852 KB Output is correct
3 Correct 92 ms 1100 KB Output is correct
4 Correct 131 ms 1024 KB Output is correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -