結果
問題 | No.15 カタログショッピング |
ユーザー |
![]() |
提出日時 | 2021-03-03 07:25:15 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 777 bytes |
コンパイル時間 | 1,805 ms |
コンパイル使用メモリ | 170,992 KB |
実行使用メモリ | 10,276 KB |
最終ジャッジ日時 | 2024-10-03 03:06:44 |
合計ジャッジ時間 | 8,408 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | TLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n,s; cin>>n>>s; vector<long long> price(n); vector<bool> bought(n,true); long long current=0; for(int i=0;i<n;i++){ cin>>price[i]; current+=price[i]; } long long lp=pow(2,n); for(long long j=0;j<lp;j++){ if(current==s){ for(int i=0;i<n;i++){ if(bought[i]){ cout<<i+1<<" "; } } cout<<endl; } for(int i=n-1;i>=0;i--){ if(bought[i]){ bought[i]=false; current-=price[i]; break; }else{ bought[i]=true; current+=price[i]; } } } }