結果
| 問題 | No.3502 GCD Knapsack |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-29 20:54:56 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 24 ms / 2,000 ms |
| + 903µs | |
| コード長 | 643 bytes |
| 記録 | |
| コンパイル時間 | 1,985 ms |
| コンパイル使用メモリ | 330,192 KB |
| 実行使用メモリ | 8,320 KB |
| 最終ジャッジ日時 | 2026-09-07 20:21:54 |
| 合計ジャッジ時間 | 6,765 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr)
using namespace std;
using ll = long long;
ll W[200000],V[200000],a[500001];
int main() {
fast;
int n,w;
cin >> n >> w;
for(int i = 0; i < n; i++){
cin >> W[i];
}
for(int i = 0; i < n; i++){
cin >> V[i];
}
for(int i = 0; i < n; i++){
a[W[i]] += V[i];
}
ll ans = 0;
for(int i = w; i <= 500000; i++){
ll now = 0;
for(int j = i; j <= 500000; j += i){
now += a[j];
}
ans = max(ans, now);
}
cout << ans << endl;
}