Submission #00101


ソースコード

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
28
29
30
31
32
33
34
#include <bits/stdc++.h>
#define endl "\n"
#define INF INT_MAX
using namespace std;
int main(){
#define int long long
cin.tie(nullptr);ios::sync_with_stdio(false);
int n,m;
cin >>n>>m;
int Max = 0;
vector<int>cost(n),value(n);
for(int i = 0;i < n;i++)cin >>cost[i]>>value[i];
for(int bit = 0;bit < (1<<n);bit++){
int happy = 0,money = 0;
for(int i = 0;i < n;i++){
if(bit & (1<<i)){
happy += value[i];
money += cost[i];
}
}
if(money <= m){
Max = max(Max,happy);
}
}
cout <<Max<<endl;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
00_sample_00.txt AC 17 ms 604 KB
1
00_sample_01.txt AC 25 ms 432 KB
1
00_sample_02.txt AC 17 ms 512 KB
1
01_nomal_00.txt AC 68 ms 464 KB
1
01_nomal_01.txt AC 20 ms 544 KB
1
01_nomal_02.txt AC 72 ms 628 KB
1
01_nomal_03.txt AC 23 ms 576 KB
1
01_nomal_04.txt AC 19 ms 660 KB
1
02_hard_00.txt AC 17 ms 616 KB
1
02_hard_01.txt AC 66 ms 568 KB
1