답안 #928777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
928777 2024-02-17T05:42:42 Z UmairAhmadMirza Kitchen (BOI19_kitchen) C++17
100 / 100
24 ms 724 KB
#include <bits/stdc++.h>
using namespace std;
int const N=305;
int const inf=1e9;
int dp[N*N];
int n,m,k;
int main(){
  cin>>n>>m>>k;
  int arr[n];
  int total=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    total+=arr[i];
    if(arr[i]<k){
      cout<<"Impossible"<<endl;
      return 0;
    }
  }
  int chef[m];
  dp[0]=1;
  for(int i=0;i<m;i++)
    cin>>chef[i];
  for(int i=0;i<m;i++){
    for(int tot=(N*m);tot>=chef[i];tot--){
      if(dp[tot-chef[i]]==0)
        continue;
      dp[tot]=max(dp[tot-chef[i]]+min(chef[i],n),dp[tot]);
    }
  }
  for(int i=total;i<=(N*m);i++){
    if(dp[i]-1>=(k*n)){
      cout<<i-total<<endl;
      return 0;
    }
  }
  cout<<"Impossible"<<endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 604 KB Output is correct
2 Correct 20 ms 544 KB Output is correct
3 Correct 19 ms 600 KB Output is correct
4 Correct 24 ms 600 KB Output is correct
5 Correct 18 ms 552 KB Output is correct
6 Correct 10 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 14 ms 604 KB Output is correct
15 Correct 20 ms 544 KB Output is correct
16 Correct 19 ms 600 KB Output is correct
17 Correct 24 ms 600 KB Output is correct
18 Correct 18 ms 552 KB Output is correct
19 Correct 10 ms 620 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 9 ms 604 KB Output is correct
26 Correct 14 ms 564 KB Output is correct
27 Correct 8 ms 348 KB Output is correct
28 Correct 13 ms 600 KB Output is correct
29 Correct 14 ms 604 KB Output is correct
30 Correct 21 ms 724 KB Output is correct