結果
問題 | No.949 飲酒プログラミングコンテスト |
ユーザー |
|
提出日時 | 2019-12-19 02:04:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 704 bytes |
コンパイル時間 | 684 ms |
コンパイル使用メモリ | 75,500 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-06 23:17:50 |
合計ジャッジ時間 | 2,571 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 21 RE * 3 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int N; int A[3333],B[3333]; vector<int>D; bool dp[3030][3030]; main() { cin>>N; for(int i=0;i<=N;i++)cin>>A[i]; for(int i=0;i<=N;i++)cin>>B[i]; for(int i=0;i<N;i++) { int d;cin>>d;D.push_back(d); } sort(D.begin(),D.end()); reverse(D.begin(),D.end()); int ans=0; dp[0][0]=true; for(int d:D) { for(int i=0;i<=ans;i++) { int j=ans-i; if(!dp[i][j])continue; if(i<N) { int nxt=A[i+1]+B[j]; if(nxt>=d) { dp[i+1][j]=true; ans=i+j+1; } } if(j<N) { int nxt=A[i]+B[j+1]; if(nxt>=d) { dp[i][j+1]=true; ans=i+j+1; } } } } cout<<ans<<endl; }