/*
بسم الله الرحمن الرحيم
Author:
(:Muhammad Aneeq:)
*/
#include <iostream>
using namespace std;
int const N=300*300+10;
int dp[N]={};
inline void solve()
{
int n,m,k;
cin>>n>>m>>k;
int z=0;
int a[n];
for (auto& i:a)
{
cin>>i,z+=i;
if (i<0)
{
cout<<"Impossible\n";return;
}
}
dp[0]=0;
for (int i=0;i<m;i++)
{
int x;
cin>>x;
for (int j=N-x-1;j>=0;j--)
dp[j+x]=max(dp[j+x],dp[j]+min(x,n));
}
for (int i=z;i<N;i++)
{
if (dp[i]>=k*n)
{
cout<<i-z<<'\n';
return;
}
}
cout<<"Impossible\n";
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
3 ms |
816 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
4 ms |
856 KB |
Output is correct |
5 |
Incorrect |
3 ms |
604 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |