結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2021-10-08 22:27:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 167 ms / 3,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 2,258 ms |
コンパイル使用メモリ | 200,404 KB |
最終ジャッジ日時 | 2025-01-24 22:38:46 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;ll w;cin>>n>>w;vector<ll> A(n);rep(i,n) cin>>A[i];int t=1;rep(i,n) t*=3;set<ll> s;for(int bit=1;bit<t;bit++){int k=bit;ll tmp=0;rep(i,n){if(k%3==1) tmp+=A[i]/2;else if(k%3==2) tmp+=A[i];k/=3;}if(tmp==w){k=bit;int l=0,d=1;rep(i,n){if(k%3>0) l+=d;k/=3;d*=2;}s.insert(l);}}ll ans=s.size();cout<<ans<<endl;return 0;}