結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー KKT89KKT89
提出日時 2019-12-17 15:56:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,500 ms
コード長 908 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 91,524 KB
実行使用メモリ 39,192 KB
最終ジャッジ日時 2023-09-15 19:39:09
合計ジャッジ時間 3,174 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
6,316 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
6,232 KB
testcase_11 AC 50 ms
33,344 KB
testcase_12 AC 48 ms
33,488 KB
testcase_13 AC 47 ms
32,028 KB
testcase_14 AC 10 ms
14,852 KB
testcase_15 AC 36 ms
29,980 KB
testcase_16 AC 60 ms
37,360 KB
testcase_17 AC 11 ms
11,544 KB
testcase_18 AC 59 ms
38,052 KB
testcase_19 AC 50 ms
34,092 KB
testcase_20 AC 14 ms
13,164 KB
testcase_21 AC 6 ms
8,508 KB
testcase_22 AC 9 ms
12,172 KB
testcase_23 AC 3 ms
5,444 KB
testcase_24 AC 36 ms
29,104 KB
testcase_25 AC 69 ms
39,020 KB
testcase_26 AC 64 ms
38,892 KB
testcase_27 AC 65 ms
39,028 KB
testcase_28 AC 63 ms
39,192 KB
testcase_29 AC 69 ms
39,176 KB
testcase_30 AC 42 ms
39,188 KB
testcase_31 AC 26 ms
39,064 KB
testcase_32 AC 71 ms
39,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int ok[3030][3030];
int pre[3030][3030];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n+1),b(n+1),d(n);
	for(int i=0;i<n+1;i++){
		cin >> a[i];
	}
	for(int i=0;i<n+1;i++){
		cin >> b[i];
	}
	for(int i=0;i<n;i++){
		cin >> d[i];
	}
	sort(d.rbegin(),d.rend());
	for(int i=0;i<n+1;i++){
		for(int j=0;j<n+1;j++){
			pre[i][j]=n+1;
		}
	}
	int ma=0;
	pre[0][0]=-1;
	for(int i=0;i<n+1;i++){
		for(int j=0;j<n+1;j++){
			if(pre[i][j]<=n){
				ma=max(ma,i+j);
				for(int k=0;k<2;k++){
					int nx=i+(k==0);
					int ny=j+(k==1);
					if(nx<=n&&ny<=n){
						for(int l=pre[i][j]+1;l<n;l++){
							if(a[nx]+b[ny]>=d[l]){
								pre[nx][ny]=min(pre[nx][ny],l);
								break;
							}
						}
					}
				}
			}
		}
	}
	cout << ma << endl;
}
0