이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300;
const int MAX_M = 300;
const int MAX_S = 9e4;
int a[MAX_N], b[MAX_M], maxSum[MAX_S + 1];
int main() {
int n, m, k;
cin >> n >> m >> k;
for ( int i = 0; i < n; i++ )
cin >> a[i];
for ( int i = 0; i < m; i++ )
cin >> b[i];
if ( m < k ) {
cout << "Impossible\n";
return 0;
}
int sumA = 0;
for ( int i = 0; i < n; i++ ) {
sumA += a[i];
if ( a[i] < k ) {
cout << "Impossible\n";
return 0;
}
}
for ( int s = 0; s <= MAX_S; s++ )
maxSum[s] = -MAX_S - 1;
maxSum[0] = 0;
for ( int i = 0; i < m; i++ ) {
for ( int s = MAX_S; s >= b[i]; s-- )
maxSum[s] = max( maxSum[s], maxSum[s - b[i]] + min( b[i], n ) );
}
int wasted = 0;
while ( sumA + wasted <= MAX_S && maxSum[sumA + wasted] < n * k )
wasted++;
if ( sumA + wasted > MAX_S )
cout << "Impossible\n";
else
cout << wasted;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |