結果
問題 | No.1163 I want to be a high achiever |
ユーザー |
|
提出日時 | 2022-10-22 14:20:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 918 bytes |
コンパイル時間 | 1,716 ms |
コンパイル使用メモリ | 196,364 KB |
最終ジャッジ日時 | 2025-02-08 11:18:13 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 29 WA * 1 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,X; cin >> N >> X; vector<int> A(N), B(N); int BASE = 100; rep(i,N) cin >> A[i], A[i] -= X, A[i] += BASE; rep(i,N) cin >> B[i]; int BSUM = accumulate(B.begin(), B.end(), 0); int MAX = 200 * 500; vector<int> dp(MAX + 1, 1e9); dp[0] = 0; rep(i,N) { vector<int> nt = dp; for(int s = 0; s <= MAX; s++) { if(s + A[i] <= MAX) nt[s + A[i]] = min(nt[s + A[i]], dp[s]); if(s + BASE <= MAX) nt[s + BASE] = min(nt[s + BASE], dp[s] + B[i]); } swap(nt, dp); } int ans = 1e9; for(int s = BASE * N; s <= MAX; s++) ans = min(ans, dp[s]); cout << (ans == int(1e9) ? -1 : ans) << endl; }