結果

問題 No.1701 half price
ユーザー hiro71687khiro71687k
提出日時 2023-08-10 05:08:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 4,535 ms
コンパイル使用メモリ 269,240 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 22:28:26
合計ジャッジ時間 6,023 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 44 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 43 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 436 ms
6,944 KB
testcase_07 AC 444 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 455 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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)
        {
            memo[z]++;
        }
    }for(auto v:memo){
        ans++;
    }
    cout << ans << endl;
}
0