結果

問題 No.1163 I want to be a high achiever
ユーザー chocoruskchocorusk
提出日時 2020-08-12 00:29:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,190 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 127,224 KB
実行使用メモリ 199,384 KB
最終ジャッジ日時 2024-04-17 17:59:11
合計ジャッジ時間 4,684 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 100 ms
199,160 KB
testcase_05 AC 97 ms
199,224 KB
testcase_06 AC 98 ms
199,352 KB
testcase_07 AC 100 ms
199,268 KB
testcase_08 AC 97 ms
199,344 KB
testcase_09 AC 96 ms
199,296 KB
testcase_10 AC 94 ms
199,168 KB
testcase_11 AC 97 ms
199,368 KB
testcase_12 AC 99 ms
199,292 KB
testcase_13 AC 99 ms
199,168 KB
testcase_14 AC 95 ms
199,296 KB
testcase_15 AC 96 ms
199,296 KB
testcase_16 AC 97 ms
199,288 KB
testcase_17 AC 96 ms
199,212 KB
testcase_18 AC 100 ms
199,360 KB
testcase_19 AC 99 ms
199,296 KB
testcase_20 AC 98 ms
199,168 KB
testcase_21 AC 100 ms
199,384 KB
testcase_22 AC 100 ms
199,188 KB
testcase_23 AC 98 ms
199,296 KB
testcase_24 AC 97 ms
199,244 KB
testcase_25 AC 99 ms
199,292 KB
testcase_26 AC 98 ms
199,332 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 95 ms
199,164 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, x; cin>>n>>x;
	int a[505], b[505];
	const int geta=100;
	for(int i=0; i<n; i++){
		cin>>a[i];
		a[i]-=x;
		a[i]+=geta;
	}
	int s=0;
	for(int i=0; i<n; i++){
	    cin>>b[i];
	    s+=b[i];
	}
	int dp[501][200*500+1];
	const int INF=1e9+7;
	for(int i=0; i<=n; i++) for(int j=0; j<=2*geta*n; j++) dp[i][j]=INF;
	dp[0][0]=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<=2*geta*i; j++){
			dp[i+1][j+a[i]]=min(dp[i+1][j+a[i]], dp[i][j]);
			dp[i+1][j+geta]=min(dp[i+1][j+geta], dp[i][j]+b[i]);
		}
	}
	int ans=s;
	for(int i=geta*n; i<=2*geta*n; i++) ans=min(ans, dp[n][i]);
	if(ans<s) cout<<ans<<endl;
	else cout<<-1<<endl;
	return 0;
}
0