結果
| 問題 |
No.2329 Nafmo、イカサマをする
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-04 23:06:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,070 bytes |
| コンパイル時間 | 817 ms |
| コンパイル使用メモリ | 96,020 KB |
| 実行使用メモリ | 53,324 KB |
| 最終ジャッジ日時 | 2024-07-18 18:07:00 |
| 合計ジャッジ時間 | 5,667 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 TLE * 1 -- * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:41:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
41 | 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>
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;
}