이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
#define int ll
const ll mod = 1e9 + 7;
int n, m, k, s;
int a[305], b[305], dp[2][1000001];
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>n>>m>>k;
if(m<k) return cout<<"Impossible", 0;
for(int i=1; i<=n; i++){
cin>>a[i];
s+=a[i];
if(a[i]<k) return cout<<"Impossible", 0;
}
for(int i=1; i<=m; i++) cin>>b[i];
dp[0][0]=0;
int cur=0;
for(int i=1; i<=m; i++){
for(int h=0; h<=cur; h++){
dp[1][h+b[i]]=max(dp[0][h+b[i]], dp[0][h]+min(b[i], n));
}
cur+=b[i];
for(int h=0; h<=cur; h++) dp[0][h]=dp[1][h];
}
//cout<<"xd";
for(int h=s; h<=cur; h++){
//cout<<h<<" "<<dp[0][h]<<endl;
if(dp[0][h]>=n*k) return cout<<h-s, 0;
}
cout<<"Impossible";
}
컴파일 시 표준 에러 (stderr) 메시지
kitchen.cpp:1:0: warning: ignoring #pragma optimize [-Wunknown-pragmas]
#pragma optimize("Ofast")
# | 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... |