結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2023-08-10 05:10:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 440 ms / 3,000 ms |
コード長 | 924 bytes |
コンパイル時間 | 4,018 ms |
コンパイル使用メモリ | 255,952 KB |
最終ジャッジ日時 | 2025-02-16 00:29:21 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using namespace std;using ll=long long;using ld=long double;ld pie=3.141592653589793;ll mod=1000000007;ll inf=10099999999999990;int main(){ll n,w;cin >> n >> w;vector<ll>a(n);for (ll i = 0; i < n; i++){cin >> a[i];}vector<ll>thr(20,1),two(20,1);for (ll i = 1; i < 20; i++){thr[i]=thr[i-1]*3;two[i]=two[i-1]*2;}ll ans=0;map<ll,ll>memo;for (ll i = 0; i <thr[n] ; i++){ll x=0;ll z=0;for (ll j = 0; j < n; j++){ll y=i%thr[j+1];y/=thr[j];x+=(a[j]*y)/2;if (y>=1){z+=two[j];}}if (x==w&&z>=1){memo[z]++;}}for(auto v:memo){ans++;}cout << ans << endl;}