結果
問題 | No.949 飲酒プログラミングコンテスト |
ユーザー |
![]() |
提出日時 | 2019-12-12 01:04:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 322 ms / 2,500 ms |
コード長 | 1,650 bytes |
コンパイル時間 | 770 ms |
コンパイル使用メモリ | 74,964 KB |
実行使用メモリ | 38,332 KB |
最終ジャッジ日時 | 2024-06-24 08:13:37 |
合計ジャッジ時間 | 5,034 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 39 | scanf("%d", &b[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:42:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d", &d[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <iterator> #include <assert.h> #pragma warning(disable:4996) typedef long long ll; #define MIN(a, b) ((a)>(b)? (b): (a)) #define MAX(a, b) ((a)<(b)? (b): (a)) #define LINF 9223300000000000000 #define INF 2140000000 const long long MOD = 1000000007; //const long long MOD = 998244353; using namespace std; int dp[3005][3005]; int main(int argc, char* argv[]) { int n; scanf("%d", &n); vector<int> a(n+1),b(n+1),d(n); int i,j; for(i=0; i<n+1; i++) { scanf("%d", &a[i]); } for(i=0; i<n+1; i++) { scanf("%d", &b[i]); } for(i=0; i<n; i++) { scanf("%d", &d[i]); } sort(d.begin(), d.end()); int l=0, r=n+1; while(r-l>1) { int m=(l+r)/2; for(i=0; i<=n; i++) { for(j=0; j<=n; j++) { dp[i][j]=0; } } dp[0][0]=1; int k; for(k=1; k<=m; k++) { int found=0; for(i=0; i<=k; i++) { int j=k-i; if((i>0 && dp[i-1][j])||(j>0 && dp[i][j-1])) { if(a[i]+b[j]>=d[m-k]) { dp[i][j]=1; found=1; } } } if(found==0) break; } if(k==m+1) { //ok l=m; } else { r=m; } } printf("%d\n", l); return 0; }