結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-11-12 15:33:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 2,000 ms |
| コード長 | 372 bytes |
| コンパイル時間 | 900 ms |
| コンパイル使用メモリ | 69,120 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 19:12:23 |
| 合計ジャッジ時間 | 2,431 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main(){
int N, K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++){
cin >> A[i];
}
int ans = 0;
for (int i = 0; i < (1 << N); i++){
int s = 0;
for (int j = 0; j < N; j++){
if (i >> j & 1){
s += A[j];
}
}
if (s <= K){
ans = max(ans, s);
}
}
cout << ans << endl;
}
SSRS