結果

問題 No.2329 Nafmo、イカサマをする
ユーザー HIcoderHIcoder
提出日時 2023-07-04 23:06:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,070 bytes
コンパイル時間 901 ms
コンパイル使用メモリ 93,920 KB
実行使用メモリ 51,096 KB
最終ジャッジ日時 2023-09-25 22:27:52
合計ジャッジ時間 6,113 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,480 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 106 ms
6,664 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 156 ms
7,932 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 479 ms
12,252 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 5 ms
4,380 KB
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:41:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   41 |         auto [v,d]=pq.top();
      |              ^

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;

int main(){
    int N,K;
    ll M;
    cin>>N>>M>>K;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    /*
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    
    ll ans=min(A[0]*K,M);
    cout<<ans<<endl;
    */
   
    priority_queue<P,vector<P>,greater<P>> pq;
    //priority_queue<ll,vector<ll>,greater<ll>> pq;
    
    set<ll> st;

    pq.emplace(0,0);
    while(!pq.empty()){
        auto [v,d]=pq.top();
        pq.pop();
        if(st.count(v)) continue;


        st.insert(v);

        if(d<K){
            for(int i=0;i<N;i++){
                if(!st.count(v+A[i]) && v+A[i]<=M){
                    pq.emplace(v+A[i],d+1);
                }
            }
        }
    }

    ll ans=*st.rbegin();
    cout<<ans<<endl;
}
0