Submission #00044


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long long m;
cin >> n >> m;
long long c[n], v[n];
for (int i = 0; i < n; i++) {
cin >> c[i] >> v[i];
}
long long Max = 0;
for (int bit = 0; bit < (1 << n); bit++) {
long long vs = 0, cs = 0;
for (int i = 0; i < n; i++) {
if (bit & (1 << i)) {
vs += v[i];
cs += c[i];
}
}
if (cs <= m) {
Max = max(Max, vs);
}
}
cout << Max << "\n";
return(0);
}

ステータス

項目 データ
問題 0012 - うっちーとうっちーのおかいもの
ユーザー名 woody_1227
投稿日時 2023-11-13 09:16:46
言語 C++17
状態 Accepted
得点 50
ソースコード長 596 Byte
最大実行時間 65 ms
最大メモリ使用量 656 KB

セット

セット 得点 Cases
1 ALL 50 / 50 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
00_sample_00.txt AC 17 ms 600 KB
1
00_sample_01.txt AC 19 ms 440 KB
1
00_sample_02.txt AC 22 ms 404 KB
1
01_nomal_00.txt AC 65 ms 500 KB
1
01_nomal_01.txt AC 14 ms 604 KB
1
01_nomal_02.txt AC 65 ms 580 KB
1
01_nomal_03.txt AC 21 ms 556 KB
1
01_nomal_04.txt AC 21 ms 656 KB
1
02_hard_00.txt AC 21 ms 624 KB
1
02_hard_01.txt AC 61 ms 592 KB
1