結果
| 問題 | No.3502 GCD Knapsack |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 15:08:16 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 705 ms / 2,000 ms |
| コード長 | 3,780 bytes |
| 記録 | |
| コンパイル時間 | 3,846 ms |
| コンパイル使用メモリ | 339,516 KB |
| 実行使用メモリ | 8,832 KB |
| 最終ジャッジ日時 | 2026-04-18 15:08:39 |
| 合計ジャッジ時間 | 21,062 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a-1; i >= b; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<vvvll> vvvvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<bool> vb;
typedef vector<vd> vvb;
typedef vector<vvd> vvvb;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef tuple<int, int, int> tui3;
typedef tuple<ll, ll, ll> tull3;
typedef priority_queue<int, vector<int>, greater<int>> pqi;
typedef priority_queue<vi, vector<vi>, greater<vi>> pqvi;
typedef priority_queue<pi, vector<pi>, greater<pi>> pqpi;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqll;
typedef priority_queue<vll, vector<vll>, greater<vll>> pqvll;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll;
typedef priority_queue<pll, vector<pll>, less<pll>> rpqpll;
typedef priority_queue<int, vector<int>, less<int>> rpqi;
typedef priority_queue<vi, vector<vi>, less<vi>> rpqvi;
typedef priority_queue<tui3, vector<tui3>, greater<tui3>> pqtui3;
typedef priority_queue<tui3, vector<tui3>, less<tui3>> rpqtui3;
typedef priority_queue<tull3, vector<tull3>, greater<tull3>> pqtull3;
typedef priority_queue<tull3, vector<tull3>, less<tull3>> rpqtull3;
#define yes(ans) if(ans)cout << "yes"<< endl; else cout << "no" << endl
#define Yes(ans) if(ans)cout << "Yes"<< endl; else cout << "No" << endl
#define YES(ans) if(ans)cout << "YES"<< endl ;else cout << "NO" << endl
#define pos(ans) if(ans)cout << "Possible"<< endl ;else cout << "Impossible" << endl
#define printv(vec) {rep(i, 0, vec.size()) cout << vec[i] << ' '; cout << endl;}
#define printvv(vec) rep(i, 0, vec.size()) {rep(j, 0, vec[i].size()) cout << vec[i][j] << ' '; cout << endl;};
#define printvvv(vec) rep(i, 0, vec.size()) { rep(j, 0, vec[i].size()) { rep(k, 0, vec[i][j].size()) cout << vec[i][j][k] << ' '; cout << " "; }cout << endl; };
#define all(x) x.begin(), x.end()
#define so(x) sort(all(x))
#define re(x) reverse(all(x))
#define rso(x) sort(x.rbegin(), x.rend())
#define vco(x, a) count(all(x), a)
#define per(x) next_permutation(all(x))
#define out(x) cout << x << endl
#define iINF 2147483647
#define llINF 9223372036854775807
#define INF 4000000000000000000
#define mod 998244353
#define mod2 1000000007
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
vi e_d(int N) {
vi res;
for (int i = 1; i * i <= N; ++i) {
if (N % i == 0) {
res.push_back(i);
if (N/i != i) res.push_back(N/i);
}
}
sort(res.begin(), res.end());
return res;
}
int main() {
int n, w; cin >> n >> w;
vll vec(3e5);
vll x(n), y(n);
ll ans = 0;
rep(i, 0, n) cin >> x[i];
rep(i, 0, n) cin >> y[i];
rep(i, 0, n){
ll a = x[i];
ll b = y[i];
vi list = e_d(int(a));
for (auto p:list){
if(p>=w){
vec[p] += b;
chmax(ans, vec[p]);
}
}
}
cout << ans << endl;
}