結果

問題 No.1463 Hungry Kanten
ユーザー MtSakaMtSaka
提出日時 2021-04-02 18:01:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 724 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 170,292 KB
実行使用メモリ 15,776 KB
最終ジャッジ日時 2023-08-25 14:45:46
合計ジャッジ時間 2,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 196 ms
15,776 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 15 ms
4,736 KB
testcase_18 AC 9 ms
4,380 KB
testcase_19 AC 77 ms
9,600 KB
testcase_20 AC 108 ms
10,844 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i, s, n) for (long long i=s;i<(long long)(n);i++)
using ll=long long;
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    assert(n<=18);
    assert(2<=n);
    assert(k<=n);
    int cnt=0;
    int a[30];
    int i=0;
    int p;
    while(cin>>p){
        assert(p<=1000);
        a[i]=p;
        cnt++;
        i++;
    }
    assert(cnt==n);
  set<ll>s;
    rep(i,(1<<k)-1,(1<<n)){
        ll sum=0,cnt=0,pro=1;
        rep(j,0,n){
            if((1<<j)&i){
                cnt++;
                sum+=a[j];
                pro*=a[j];
            }
        }
        if(cnt>=k){
            s.insert(sum);
            s.insert(pro);
        }
    }
    cout<<s.size()<<endl;
}
0