結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー 👑 kmjpkmjp
提出日時 2019-12-12 00:28:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,500 ms
コード長 1,281 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 168,120 KB
実行使用メモリ 40,480 KB
最終ジャッジ日時 2023-09-06 13:37:18
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,460 KB
testcase_01 AC 2 ms
5,448 KB
testcase_02 AC 2 ms
5,440 KB
testcase_03 AC 1 ms
5,420 KB
testcase_04 AC 2 ms
5,504 KB
testcase_05 AC 2 ms
5,660 KB
testcase_06 AC 2 ms
5,632 KB
testcase_07 AC 3 ms
6,092 KB
testcase_08 AC 4 ms
8,300 KB
testcase_09 AC 3 ms
6,112 KB
testcase_10 AC 3 ms
8,248 KB
testcase_11 AC 42 ms
36,120 KB
testcase_12 AC 39 ms
36,140 KB
testcase_13 AC 38 ms
34,096 KB
testcase_14 AC 9 ms
17,144 KB
testcase_15 AC 30 ms
32,056 KB
testcase_16 AC 50 ms
40,252 KB
testcase_17 AC 10 ms
17,048 KB
testcase_18 AC 49 ms
40,240 KB
testcase_19 AC 44 ms
36,136 KB
testcase_20 AC 12 ms
19,184 KB
testcase_21 AC 6 ms
14,796 KB
testcase_22 AC 10 ms
19,132 KB
testcase_23 AC 3 ms
8,508 KB
testcase_24 AC 29 ms
32,020 KB
testcase_25 AC 56 ms
40,296 KB
testcase_26 AC 52 ms
40,480 KB
testcase_27 AC 53 ms
40,248 KB
testcase_28 AC 52 ms
40,216 KB
testcase_29 AC 61 ms
40,212 KB
testcase_30 AC 40 ms
40,360 KB
testcase_31 AC 25 ms
40,300 KB
testcase_32 AC 60 ms
40,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[3030];
int B[3030];
int ok[3030][3030];
int D[3030];
int pre[3030][3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N+1) cin>>A[i];
	FOR(i,N+1) cin>>B[i];
	FOR(i,N) cin>>D[i];
	
	sort(D,D+N);
	reverse(D,D+N);
	FOR(x,N+1) FOR(y,N+1) pre[x][y]=N+1;
	pre[0][0]=-1;
	
	int ma=0;
	FOR(x,N+1) FOR(y,N+1) if(pre[x][y]<=N) {
		ma=max(ma,x+y);
		FOR(i,2) {
			int nx=x+(i==0);
			int ny=y+(i==1);
			if(nx<=N && ny<=N) {
				
				for(j=pre[x][y]+1;j<N;j++) {
					if(A[nx]+B[ny]>=D[j]) {
						pre[nx][ny]=min(pre[nx][ny],j);
						break;
					}
				}
			}
		}
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0