Submission #00034
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <bits/stdc++.h> using namespace std; int main(){ int N; long long M; scanf ( "%d %lld" ,&N,&M); long long C[N],V[N]; for ( int i=0;i<N;i++) scanf ( "%lld %lld" ,C+i,V+i); long long ans=0,sum,value; for ( int bit=0;bit<(1<<N);bit++){ sum=0; value=0; for ( int i=0;i<N;i++){ if (bit&(1<<i)){ sum+=C[i]; value+=V[i]; } } if (sum<=M) ans=max(ans,value); } printf ( "%lld\n" ,ans); return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0007 - うっちーとうっちーのおかいもの |
ユーザー名 | ei2122 |
投稿日時 | 2023-07-18 16:22:42 |
言語 | C++17 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 543 Byte |
最大実行時間 | 67 ms |
最大メモリ使用量 | 516 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
00_sample_00.txt | AC | 20 ms | 476 KB |
1
|
00_sample_01.txt | AC | 19 ms | 444 KB |
1
|
00_sample_02.txt | AC | 19 ms | 416 KB |
1
|
01_nomal_00.txt | AC | 64 ms | 516 KB |
1
|
01_nomal_01.txt | AC | 16 ms | 488 KB |
1
|
01_nomal_02.txt | AC | 67 ms | 460 KB |
1
|
01_nomal_03.txt | AC | 21 ms | 432 KB |
1
|
01_nomal_04.txt | AC | 20 ms | 404 KB |
1
|
02_hard_00.txt | AC | 27 ms | 376 KB |
1
|
02_hard_01.txt | AC | 67 ms | 484 KB |
1
|