結果
問題 |
No.1163 I want to be a high achiever
|
ユーザー |
|
提出日時 | 2020-09-09 20:09:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 248 ms / 2,000 ms |
コード長 | 657 bytes |
コンパイル時間 | 729 ms |
コンパイル使用メモリ | 67,712 KB |
実行使用メモリ | 260,000 KB |
最終ジャッジ日時 | 2024-12-16 05:25:03 |
合計ジャッジ時間 | 7,842 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N,X,A[505]; int B[505],dp[505][1<<17]; const int off=1<<16; main() { for(int i=0;i<1<<17;i++)dp[0][i]=1e9; dp[0][off]=0; cin>>N>>X; bool out=true; for(int i=0;i<N;i++) { cin>>A[i]; if(A[i]>=X)out=false; } if(out) { cout<<-1<<endl; return 0; } for(int i=0;i<N;i++)cin>>B[i]; for(int i=0;i<N;i++) { for(int j=0;j<1<<17;j++)dp[i+1][j]=dp[i][j]+B[i]; int di=A[i]-X; for(int j=0;j<1<<17;j++) { if(j+di<1<<17&&j+di>=0) { dp[i+1][j+di]=min(dp[i+1][j+di],dp[i][j]); } } } int ans=1e9; for(int j=off;j<1<<17;j++)ans=min(ans,dp[N][j]); cout<<ans<<endl; }