답안 #1048092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048092 2024-08-07T22:23:23 Z Braabebo10 Kitchen (BOI19_kitchen) C++17
21 / 100
93 ms 221028 KB
#include <bits/stdc++.h>
#define ll long long
#define nl "\n"
#define yes "YES"
#define no "NO"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll N=301;
ll n,m,k;
vector<ll>a,b;
ll dp[N+10][N*N+10];
ll solve(ll i,ll j){
    if(j<0)return -1e14;
    if(i==m)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    ll op1=solve(i+1,j);
    ll op2=solve(i+1,j-b[i])+min(b[i],n);
    return dp[i][j]=max(op1,op2);
}
int main() {
    fast
    memset(dp,-1, sizeof(dp));
    cin>>n>>m>>k;
    a=vector<ll>(n);
    b=vector<ll>(m);
    ll sm=0,sm2=0;
    bool ok=1;
    for(ll &i:a)cin>>i,sm+=i,ok&=(i>=k);
    for(ll &i:b)cin>>i,sm2+=i;
    if(!ok){
        cout<<"Impossible"<<nl;
        return 0;
    }
    for(ll i=sm;i<=sm*sm;i++){
        if(solve(0,i)>=n*k){
            cout<<i-sm<<nl;
            return 0;
        }
    }
    cout<<"Impossible"<<nl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 220912 KB Output is correct
2 Incorrect 53 ms 221020 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 220912 KB Output is correct
2 Incorrect 53 ms 221020 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 221008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 221008 KB Output is correct
2 Correct 52 ms 220820 KB Output is correct
3 Correct 52 ms 221012 KB Output is correct
4 Correct 61 ms 221028 KB Output is correct
5 Correct 54 ms 220912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 220912 KB Output is correct
2 Incorrect 53 ms 221020 KB Output isn't correct
3 Halted 0 ms 0 KB -