結果
| 問題 | No.3670 Fast Knapsack |
| コンテスト | |
| ユーザー |
harurun
|
| 提出日時 | 2026-08-06 03:40:27 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 711 bytes |
| 記録 | |
| コンパイル時間 | 3,848 ms |
| コンパイル使用メモリ | 378,632 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-09-04 22:06:36 |
| 合計ジャッジ時間 | 10,389 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 TLE * 1 -- * 22 |
ソースコード
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void solve(){
int N,S;
cin>>N>>S;
vector<int> A(N);
for(int i=0;i<N;i++){
cin>>A[i];
}
vector<bool> dp(S+1);
dp[0]=1;
for(int i:A){
for(int j=S-1;j>=0;j--){
if(dp[j] && j+i<=S){
dp[j+i]=1;
}
}
}
for(int i=S;i>=0;i--){
if(dp[i]){
cout<<i<<"\n";
return;
}
}
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
cin>>T;
while(T--){
solve();
}
}
harurun