답안 #797001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797001 2023-07-29T03:46:23 Z kebine Kitchen (BOI19_kitchen) C++17
0 / 100
1000 ms 324 KB
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define pqueue priority_queue
#define int long long
#define pii pair<int,int>
#define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
using namespace std;
int tc,ans=0,n,m,k;
int sum;
int a[305];
int b[305];
void dp(int idx,int taken,int tot){
  if(taken>=k&&taken<=m){
    if(tot>=sum){
      ans=min(ans,tot);
      return;
    }
  }
  if(idx>m){
    return;
  }
  for(int i=idx+1;i<=m+1;i++){
    dp(i,taken+1,tot+b[i]);
  }
}
main(){
  supercepat;
  cin>>n>>m>>k;
  bool ok=1;
  for(int i=1;i<=n;i++){
    cin>>a[i]; if(a[i]<k) ok=0;
    sum+=a[i];
  }
  for(int i=1;i<=m;i++){
    cin>>b[i];
  }
  ans=LLONG_MAX;
  if(m<k) ok=0;
  if(!ok) cout<<"Impossible"<<endl;
  else{
    dp(0,0,0);
    if(ans==LLONG_MAX) cout<<"Impossible"<<endl;
    else cout<<ans-sum<<endl;
  }
}
/*
dp(idx,taken,sum);

transisi
for(i=idx+1;i<=m+1;i++)
  dp(i,taken+1,sum+b[i])
  
base 
if(i
if(taken>=k&&taken<=m)
  if(sum>=sum2)
    ans=min(ans,sum)
    return;

*/


Compilation message

kitchen.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -