結果
| 問題 |
No.2329 Nafmo、イカサマをする
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-04 23:18:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,269 bytes |
| コンパイル時間 | 956 ms |
| コンパイル使用メモリ | 104,588 KB |
| 実行使用メモリ | 56,412 KB |
| 最終ジャッジ日時 | 2024-07-18 18:22:05 |
| 合計ジャッジ時間 | 5,566 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 TLE * 2 -- * 1 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:45:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
45 | auto [v,d]=pq.top();
| ^
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
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;
//unordered_set<ll> st;
set<ll> st;
st.insert(0);
pq.emplace(0,K);
while(!pq.empty()){
auto [v,d]=pq.top();
pq.pop();
if(st.count(M)) break;
if(d>0){
for(int i=0;i<N;i++){
if(!st.count(v+A[i]) && v+A[i]<=M){
st.insert(v+A[i]);
pq.emplace(v+A[i],d-1);
}
}
}
}
/*
ll ans=0;
for(ll v:st){
ans=max(ans,v);
}
*/
ll ans=*st.rbegin();
cout<<ans<<endl;
}